제출 #651391

#제출 시각아이디문제언어결과실행 시간메모리
651391AlanHandcrafted Gift (IOI20_gift)C++17
10 / 100
180 ms24804 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]--; } for (int i = 1; i < n; i++) d[i] += d[i-1]; bool r = true; for (int i = 0; i < n; i++) { if (!d[i]) 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]] : 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...