제출 #301591

#제출 시각아이디문제언어결과실행 시간메모리
301591kevinsogoHandcrafted Gift (IOI20_gift)C++17
100 / 100
190 ms17020 KiB
#include "gift.h" #include <bits/stdc++.h> using namespace std; int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x) { vector<int> same(n); for (int i = 0; i < r; i++) { if (x[i] == 1) { same[a[i]]++; same[b[i]]--; } } for (int i = 0; i < n - 1; i++) same[i + 1] += same[i]; assert(same.back() == 0); vector<int> diff(n); for (int i = 0; i < n - 1; i++) diff[i + 1] = diff[i] + !same[i]; for (int i = 0; i < r; i++) { if (x[i] == 1) assert(diff[a[i]] == diff[b[i]]); if (x[i] == 2 && diff[a[i]] == diff[b[i]]) return 0; } string s(n, 'R'); for (int i = 0; i < n - 1; i++) { s[i + 1] = s[i] ^ (!same[i] * ('R' ^ 'B')); } 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...