Play Stupid Games, Win Stupid Prizes
Continuing Loops, While There Are Some Things To Do Below It
This is the compilations of some stupid mistakes I made, maybe I’ll keep this milestone as a bookmark to show how stupid I am.
1
2
3
4
5
6
7
for(int j = i + 1;j <= n;j += 2){
// .. emptied because its long
if(sz(antri) > 1) continue; // Continue
// do stupid things here
if(j + 1 <= n) antri.push_back(isi[j + 1]); // This should be done regardless of the result
}
Fix
1
2
3
4
5
6
7
for(int j = i + 1;j <= n;j += 2){
// .. emptied because its long
if(sz(antri) == 1){
// do stupid things here
}
if(j + 1 <= n) antri.push_back(isi[j + 1]);
}
Lesson learned: Doing a complement continue is actually a bad practice. Should avoid this at any cost from now.
Breaking Reading Inputs in Multi Test Cases
This is so stupid. Self explanatory
1
2
3
4
5
6
7
8
int solve() {
int n; cin >> n;
vector <int> isi(n + 1);
for (int i = 1; i <= n; i++) {
cin >> isi[i];
if(isi[i] == 0) return 0;
}
}
Stupid Ceiling
This can’t handle when $a = 0$… So stupid
1
2
3
LL ceil(LL a, LL b){
return (a-1)/b+1;
}
Instead, do ceil by a/b + !!(a%b)
Leave a Comment