Submission #303354

#TimeUsernameProblemLanguageResultExecution timeMemory
303354Kevin_Zhang_TWComparing Plants (IOI20_plants)C++17
0 / 100
1 ms384 KiB
#include "plants.h" #include<bits/stdc++.h> #define pb emplace_back using namespace std; using ll = long long; #define KEV #ifdef KEV #define DE(a, b) cerr << #a << ' ' << a << b void debug(auto L, auto R) { while (L != R) cerr << *L << " \n"[L+1==R], ++L; } #else #define DE(...) 0 void debug(...) {} #endif const int maxn = 300010; #define LB(V, i) lower_bound(begin(V), end(V), i) #define UB(V, i) upper_bound(begin(V), end(V), i) #define PI pair<int,int> int n, k; vector<int> r, tu[2]; set<pair<int,int>> win; int F(int i) { return (i+n) % n; } void build2() { for (int i = 0;i < n;++i) { if (r[i] != r[F(i+1)]) tu[ r[i] ].pb(F(i+1)); win.insert( r[i] ? PI{F(i+1), i} : PI{i, F(i+1)}); } for (int i : {0, 1}) sort(begin(tu[i]), end(tu[i])); tu[0].pb(tu[0][0] + n); tu[1].pb(tu[1][0] + n); } void init(int k, std::vector<int> r) { ::k = k; ::r = r; n = r.size(); if (k == 2) build2(); return; } pair<int,int> get(int i) { return {*LB(tu[0], i), *LB(tu[1], i)}; } int compare_plants(int x, int y) { if (k == 2) { if (win.count(PI{x, y})) return 1; if (win.count(PI{y, x})) return -1; auto [a, b] = get(x); auto [c, d] = get(y); DE(a, ' '), DE(b, '\n'); DE(c, ' '), DE(d, '\n'); if (F(min(a, b)) == F(min(c, d))) { if (min(a, b) >= n) x -= n; if (min(c, d) >= n) y -= n; if (a < b) return x < y ? -1 : 1; else return x < y ? 1 : -1; } } return 0; }

Compilation message (stderr)

plants.cpp:10:12: warning: use of 'auto' in parameter declaration only available with '-fconcepts'
   10 | void debug(auto L, auto R) { while (L != R) cerr << *L << " \n"[L+1==R], ++L; }
      |            ^~~~
plants.cpp:10:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts'
   10 | void debug(auto L, auto R) { while (L != R) cerr << *L << " \n"[L+1==R], ++L; }
      |                    ^~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...