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 | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | 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 | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
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 |
---|