problem E, why sthe same code in GNU C++17 got tle, in Clang++20 Diagnostics got ac???
ac: https://mirror.codeforces.com/contest/1698/submission/162327659
tle: https://mirror.codeforces.com/contest/1698/submission/162327699
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
problem E, why sthe same code in GNU C++17 got tle, in Clang++20 Diagnostics got ac???
ac: https://mirror.codeforces.com/contest/1698/submission/162327659
tle: https://mirror.codeforces.com/contest/1698/submission/162327699
#include <bits/stdc++.h>
using namespace std;
int Min(int a, int b) {return a < b ? a : b;}
template<class T,int N,T (*fun)(T,T)> struct SparseTable{
int lg[N+10],n;
T f[21][N+10];
int pw(int x){return 1<<x;}
SparseTable():n(0){lg[0]=-1;}
void insert(T x){
f[0][++n]=x,lg[n]=lg[n>>1]+1;
for(int t=1;pw(t)<=n;t++){
int i=n-pw(t)+1;
f[t][i]=fun(f[t-1][i],f[t-1][i+pw(t-1)]);
}
}
T query(int l,int r){
int len=lg[r-l+1];
return fun(f[len][l],f[len][r-pw(len)+1]);
}
};
int main() {
SparseTable<int,100010, Min> t;//compile succussfully
// SparseTable<int,100010, min> t;//compile failed
return 0;
}
Could you give me a suggestion? I wonder that in competitive programming debugging with gdb will improve efficiency or not? Now I just use IDE such as Dev Cpp, print something for debugging. Is necessary for me to learn gdb and use it in debugging for competitive programming? If you could gvie me advice, I would so grateful.
Name |
---|