Submission #651395

#TimeUsernameProblemLanguageResultExecution timeMemory
651395AlanHandcrafted Gift (IOI20_gift)C++17
100 / 100
220 ms24596 KiB
#include <bits/stdc++.h> #include "gift.h" using namespace std; int construct(int n, int m, vector<int> a, vector<int> b, vector<int> x) { string s (n, 0); vector<int> d (n+1), ps (n+1); for (int i = 0; i < m; i++) if (x[i] == 1) { d[a[i]]++; d[b[i]+1]--; } bool r = true; for (int i = 0; i < n; i++) { if (i) d[i] += d[i-1]; if (!d[i] || (i && !d[i-1])) r = !r; s[i] = r ? 'R' : 'B'; ps[i] += s[i] == 'B'; if (i) ps[i] += ps[i-1]; } for (int i = 0; i < m; i++) if (x[i] == 2) { int diff = ps[b[i]] - (a[i] ? ps[a[i]-1] : 0); if (diff == 0 || diff == b[i]-a[i]+1) return 0; } craft(s); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...