Submission #303354

# Submission time Handle Problem Language Result Execution time Memory
303354 2020-09-20T08:52:22 Z Kevin_Zhang_TW Comparing Plants (IOI20_plants) C++17
0 / 100
1 ms 384 KB
#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

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 time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Incorrect 1 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Incorrect 1 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -