Submission #480905

#TimeUsernameProblemLanguageResultExecution timeMemory
480905malarHandcrafted Gift (IOI20_gift)C++14
0 / 100
1583 ms21516 KiB
#include <bits/stdc++.h> #include "gift.h" using namespace std; #include <algorithm> #include <vector> #include <cassert> #include <cstdio> #include <string> vector<int>parent; int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) { parent.resize(n); for(int l=0;l<n;l++) parent[l]=l; for(int i = 0; i < r; i++){ if(x[i] == 2) continue; bool found = false; int search = a[i]; vector<int>::iterator it; int index; do { it = find(parent.begin(), parent.end(), search); index = std::distance(parent.begin(), it); if(index <= b[i]) { found=true; } search++; } while(!found && it == parent.end()); if(parent[index] <= b[i]) { while(index <= b[i] && index != n) { parent[index] = b[i]; index++; } } } for(int i=0; i < r; i++) { if(x[i] == 1) continue; if(a[i] == b[i]) return 0; int k = a[i]; while(k < b[i]-1) { if(parent[k] == parent[k+1]) return 0; k++; } } string s ="R"; for(int i=1;i<n;i++) { if(parent[i] != parent[i-1]) if(s.back() == 'R')s += "B"; else s+= "R"; else s+= s.back(); } 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...