Submission #1101106

#TimeUsernameProblemLanguageResultExecution timeMemory
1101106Beerus13Handcrafted Gift (IOI20_gift)C++14
10 / 100
154 ms31248 KiB
#include<bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i) #define FORD(i, b, a) for(int i = (b), _a = (a); i >= _a; --i) #define REP(i, a, b) for(int i = (a), _b = (b); i < _b; ++i) #define REPD(i, b, a) for(int i = (b), _a = (a); i > _a; --i) #define MASK(i) (1LL << (i)) #define BIT(mask, i) (((mask) >> (i)) & 1) #define __builtin_popcount __builtin_popcountll #define all(val) val.begin(), val.end() #define ll long long #define ull unsigned long long #define pii pair<int, int> #define pll pair<ll, ll> #define sz(v) (int)v.size() #define fi first #define se second mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll Rand(ll l, ll r) {return l + rng() % (r - l + 1);} template<class X, class Y> bool minimize(X &x, const Y &y) { if (x > y) { x = y; return true; } else return false; } template<class X, class Y> bool maximize(X &x, const Y &y) { if (x < y) { x = y; return true; } else return false; } template<class T> T Abs(const T &x) { return (x < 0 ? -x : x); } const int mod = 1e9 + 7; const int inf = 1e9; const int N = 5e5 + 5; #include "gift.h" int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x) { vector<pii> one, two; REP(i, 0, r) { if(x[i] == 1) one.emplace_back(a[i], b[i]); else two.emplace_back(a[i], b[i]); } sort(all(one)); vector<int> res(n, 0); int posL = 0, posR = 0, val = 1; if(one.size()) posL = one[0].fi, posR = one[0].se; for(auto &[l, r] : one) { if(posR >= l) posR = max(posR, r); else { FOR(i, posL, posR) res[i] = val; if((l - posR) & 1) val = 3 - val; posL = l; posR = r; } } FOR(i, posL, posR) res[i] = val; val = 1; REP(i, 0, n) { if(res[i]) val = 3 - res[i]; else res[i] = val; } vector<int> sumR(n + 1, 0), sumB(n + 1, 0); REP(i, 0, n) { sumR[i + 1] = sumR[i] + (res[i] == 1); sumB[i + 1] = sumB[i] + (res[i] == 2); } for(auto &[l, r] : two) { int red = (sumR[r + 1] - sumR[l]) > 0; int blue = (sumB[r + 1] - sumB[l]) > 0; if(red + blue != 2) return 0; } string s = ""; REP(i, 0, n) { if(res[i] == 1) s += 'R'; else s += 'B'; } craft(s); return 1; } // void process() { // int n, r; // cin >> n >> r; // vector<int> a(r), b(r), x(r); // for(int &val : a) cin >> val; // for(int &val : b) cin >> val; // for(int &val : x) cin >> val; // construct(n, r, a, b, x); // } // signed main() { // if(fopen("test.inp","r")) { // freopen("test.inp","r",stdin); // freopen("test.out","w",stdout); // } // ios::sync_with_stdio(0); // cin.tie(0); cout.tie(0); // // clock_t start = clock(); // int ntests = 1; // // cin >> ntests; // while(ntests--) process(); // // cerr << "Time elapsed: " << clock() - start << " ms!\n"; // return 0; // } // https://oj.uz/problem/view/IOI20_gift

Compilation message (stderr)

gift.cpp: In function 'int construct(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
gift.cpp:58:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   58 |     for(auto &[l, r] : one) {
      |               ^
gift.cpp:78:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   78 |     for(auto &[l, r] : two) {
      |               ^
#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...