Submission #697275

#TimeUsernameProblemLanguageResultExecution timeMemory
697275youngyojunHandcrafted Gift (IOI20_gift)C++17
100 / 100
146 ms24920 KiB
#include "gift.h" #include <bits/stdc++.h> using namespace std; int construct(int N, int K, vector<int> A, vector<int> B, vector<int> C) { vector<int> D(N); for(int i = K; i--;) if(1 == C[i] && A[i] != B[i]) { D[A[i]]++; D[B[i]]--; } for(int i = 1; i < N; i++) D[i] += D[i-1]; vector<int> E(N); for(int i = 1, c = 0; i < N; i++) { if(!D[i-1]) c ^= 1; E[i] = c; } for(int i = N; i--;) D[i] = 0; for(int i = 1; i < N; i++) D[i-1] = E[i-1] ^ E[i]; for(int i = 1; i < N; i++) D[i] += D[i-1]; for(int i = K; i--;) if(2 == C[i] && (A[i] == B[i] || D[B[i]-1] == (A[i] ? D[A[i]-1] : 0))) return 0; string ret; for(int i = 0; i < N; i++) ret += E[i] ? 'R' : 'B'; craft(ret); 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...