Submission #429833

#TimeUsernameProblemLanguageResultExecution timeMemory
429833schseHandcrafted Gift (IOI20_gift)C++17
25 / 100
721 ms19004 KiB
#include "gift.h" #include <bits/stdc++.h> using namespace std; #ifndef EVAL #include "grader.cpp" #endif struct segtree { vector<int> tree = vector<int>(1 << 20, -1); void lazzy(int index) { if (tree[index] != -1) tree[index * 2] = tree[index * 2 + 1] = tree[index]; tree[index] = -1; } void iota(int index, int b, int e) { if (e - b == 1) { tree[index] = b; return; } iota(index * 2, b, (b + e) / 2); iota(index * 2 + 1, (b + e) / 2, e); } void updset(int index, int b, int e, int l, int r, int v) { if (l <= b && e <= r) { tree[index] = v; return; } if (e <= l || r <= b) return; lazzy(index); updset(index * 2, b, (b + e) / 2, l, r, v); updset(index * 2 + 1, (b + e) / 2, e, l, r, v); } int query(int index, int b, int e, int p) { if (p < b || p >= e) return 0; if (e - b == 1 && b == p) return tree[index]; lazzy(index); return query(index * 2, b, (b + e) / 2, p) + query(index * 2 + 1, (b + e) / 2, e, p); } } tree; int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) { tree.iota(1, 0, n); vector<int> prefix(n); iota(prefix.begin(), prefix.end(), 0); for (int i = 0; i < a.size(); i++) //update single color { if (x[i] == 1) { int va = tree.query(1, 0, n, a[i]); int vb = tree.query(1, 0, n, b[i]); tree.updset(1, 0, n, a[i], b[i] + 1, va); } } for (int i = 0; i < a.size(); i++) //check wetherpossible { if (x[i] == 2) { int va = tree.query(1, 0, n, a[i]); int vb = tree.query(1, 0, n, b[i]); if (vb == va) return 0; } } std::string s(n, 'R'); bool bo = true; int last = -1; for (int i = 0; i < n; i++) { int v = tree.query(1, 0, n, i); if (v != last) { last = v; bo = !bo; } s[i] = bo ? 'R' : 'B'; } craft(s); return 1; }

Compilation message (stderr)

gift.cpp: In function 'int construct(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
gift.cpp:62:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for (int i = 0; i < a.size(); i++) //update single color
      |                     ~~^~~~~~~~~~
gift.cpp:67:17: warning: unused variable 'vb' [-Wunused-variable]
   67 |             int vb = tree.query(1, 0, n, b[i]);
      |                 ^~
gift.cpp:71:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     for (int i = 0; i < a.size(); i++) //check wetherpossible
      |                     ~~^~~~~~~~~~
#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...