problem E, why sthe same code in GNU C++17 got tle, in Clang++20 Diagnostics got ac???
ac: https://codeforces.me/contest/1698/submission/162327659
tle: https://codeforces.me/contest/1698/submission/162327699
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3821 |
3 | Benq | 3736 |
4 | Radewoosh | 3631 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3388 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
problem E, why sthe same code in GNU C++17 got tle, in Clang++20 Diagnostics got ac???
ac: https://codeforces.me/contest/1698/submission/162327659
tle: https://codeforces.me/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 |
---|