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 | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
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 |
---|