There are some bugs and features exists while compiling a c++ code,it looks weird but really exists on standard c++ compiler.I'll write down the bugs and features here to remind you to aware of them.↵
# 1.stl::vector:fail to use operator "=".↵
I was trying to implent the merge function of segment tree while solving [the task](https://codeforces.me/contest/1037/problem/H),and the initial code is ↵
↵
<spoiler summary="here">↵
↵
```↵
int mrg(int x,int y,int l,int r){↵
if(x == -1 || y == -1)↵
return x + y + 1;↵
int u = sum.size();↵
sum.push_back(sum[x] + sum[y]);↵
lc.push_back(-1);↵
rc.push_back(-1);↵
if(l == r)↵
return u;↵
int m = (l + r) >> 1;↵
lc[u] = mrg(lc[x],lc[y],l,m);↵
rc[u] = mrg(rc[x],rc[y],m + 1,r);↵
return u;↵
}↵
```↵
↵
...↵
</spoiler>↵
↵
and found that it will get WA on test #6 using the language `C++14(GCC 6-32)`.Then I found out that the ↵
↵
<spoiler summary="code">↵
↵
```↵
lc[u] = mrg(lc[x],lc[y],l,m);↵
rc[u] = mrg(rc[x],rc[y],m + 1,r);↵
```↵
↵
...↵
</spoiler>↵
↵
might got wrong.That because the location of `lc[u]` changed after using `lc.push_back()` and the same as `rc[u]`,so the operator "=" might not work.↵
↵
The bug have been fixed since `C++17(GCC 7-32)`,but if you compile your code using language `C++` and the previous version before `C++17(GCC 7-32)`,the bug still exists.↵
↵
# 2.vector:Can vector be compiled by head file <algorithm>?↵
↵
I've participated on a school contest and found that a code with `stl :: vector` ran successfully without head file `<vector>`,after that,I made some testing and found something miraculous:↵
↵
If the compiler is on Windows system (on codeforces,Dev c++ on Windows,etc),you can use `<algorithm>` instead of `<vector>` to compile `stl :: vector`,but if the compiler is on Linux system (Luogu,and so on),`<algorithm>` is unable to compile `stl :: vector`.Also, in Windows `<iostream>` is able to compile `stl :: vector` too.So,for participants,especially for Chinese who is willing to engage on Olympics in informatics,please be aware of this.↵
↵
For more such bugs and features,you can reply to the comment and I'll put some of them that sometimes exists but not well-known here.
# 1.stl::vector:fail to use operator "=".↵
I was trying to implent the merge function of segment tree while solving [the task](https://codeforces.me/contest/1037/problem/H),and the initial code is ↵
↵
<spoiler summary="here">↵
↵
```↵
int mrg(int x,int y,int l,int r){↵
if(x == -1 || y == -1)↵
return x + y + 1;↵
int u = sum.size();↵
sum.push_back(sum[x] + sum[y]);↵
lc.push_back(-1);↵
rc.push_back(-1);↵
if(l == r)↵
return u;↵
int m = (l + r) >> 1;↵
lc[u] = mrg(lc[x],lc[y],l,m);↵
rc[u] = mrg(rc[x],rc[y],m + 1,r);↵
return u;↵
}↵
```↵
↵
...↵
</spoiler>↵
↵
and found that it will get WA on test #6 using the language `C++14(GCC 6-32)`.Then I found out that the ↵
↵
<spoiler summary="code">↵
↵
```↵
lc[u] = mrg(lc[x],lc[y],l,m);↵
rc[u] = mrg(rc[x],rc[y],m + 1,r);↵
```↵
↵
...↵
</spoiler>↵
↵
might got wrong.That because the location of `lc[u]` changed after using `lc.push_back()` and the same as `rc[u]`,so the operator "=" might not work.↵
↵
The bug have been fixed since `C++17(GCC 7-32)`,but if you compile your code using language `C++` and the previous version before `C++17(GCC 7-32)`,the bug still exists.↵
↵
# 2.vector:Can vector be compiled by head file <algorithm>?↵
↵
I've participated on a school contest and found that a code with `stl :: vector` ran successfully without head file `<vector>`,after that,I made some testing and found something miraculous:↵
↵
If the compiler is on Windows system (on codeforces,Dev c++ on Windows,etc),you can use `<algorithm>` instead of `<vector>` to compile `stl :: vector`,but if the compiler is on Linux system (Luogu,and so on),`<algorithm>` is unable to compile `stl :: vector`.Also, in Windows `<iostream>` is able to compile `stl :: vector` too.So,for participants,especially for Chinese who is willing to engage on Olympics in informatics,please be aware of this.↵
↵
For more such bugs and features,you can reply to the comment and I'll put some of them that sometimes exists but not well-known here.