Submission #1231163

#TimeUsernameProblemLanguageResultExecution timeMemory
1231163AndreasKHandcrafted Gift (IOI20_gift)C++20
0 / 100
1 ms324 KiB
#include <bits/stdc++.h> #include "gift.h" using namespace std; #define designed ios_base::sync_with_stdio(0); #define by cin.tie(0); #define AndreasK cout.tie(0); //#define int long long #define akinput freopen("akinput.txt", "r", stdin); #define akoutput freopen("akoutput.txt", "w", stdout); int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x) { set<int> unoccupied; for (int c = 0; c < n; c++) unoccupied.insert(c); vector<pair<pair<int, int>, int> > all; for (int c = 0; c < r; c++) all.push_back({{a[c], b[c]}, x[c]}); sort(all.begin(), all.end()); vector<int> start(n, -1); for (auto aek : all) { if (aek.second == 2) continue; if (unoccupied.count(aek.first.first)) { start[aek.first.first] = aek.first.first; for (int c = aek.first.first; c <= aek.first.second; c++) { start[c] = start[aek.first.first]; unoccupied.erase(c); } } else { auto x = unoccupied.lower_bound(aek.first.first); set<int> s; while (x != unoccupied.end() && *x <= aek.first.second) { s.insert(*x); x++; } for (auto aekole : s) { start[aekole] = start[aek.first.first]; unoccupied.erase(aekole); } } } for (int c = 0; c < n; c++) if (start[c] == -1) { for (int r = c; r < n; r++) { if (start[r] != -1) break; start[r] = n + c; } } for (int c = 0; c < r; c++) { if (x[c] == 1) { if (start[c] != start[c]) return 0; } else if (start[c] == start[c]) return 0; } string s = ""; s += '0'; for (int c = 1; c < n; c++) { if (start[c] == start[c - 1]) s += s[s.size() - 1]; else if (s[s.size() - 1] == '0') s += '1'; else s += '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...