Submission #809662

# Submission time Handle Problem Language Result Execution time Memory
809662 2023-08-06T02:50:00 Z PixelCat Comparing Plants (IOI20_plants) C++14
0 / 100
4000 ms 27780 KB
#include "plants.h"
 
#ifdef NYAOWO
#include "grader.cpp"
#endif
 
#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
// #define int LL
using namespace std;
using i32 = int32_t;
using LL = long long;
using pii = pair<int, int>;
 
const int MAXN = 200'000;
 
vector<int> adj[MAXN + 10];
vector<int> rev[MAXN + 10];
int vis[MAXN + 10];
// bitset<MAXN + 10> tal[MAXN + 10];
 
int dist(int s, int t, int n) {
    if(s <= t) return t - s;
    else return t - s + n;
}
 
// void dp(int n) {
//     if(vis[n]) return;
//     vis[n] = 1;
//     tal[n].reset();
//     for(auto &i:adj[n]) {
//         dp(i);
//         tal[n] |= tal[i];
//         tal[n][i] = 1;
//     }
// }

void owo(vector<int> *ad, int tag) {
    queue<int> que;
    que.emplace(0);
    vis[0] |= tag;
    while(!que.empty()) {
        int cur = que.front(); que.pop();
        for(auto &i:ad[cur]) if((vis[i] & tag) == 0) {
            que.emplace(i);
            vis[i] |= tag;
        }
    }
}
 
void init(int k, vector<int> r) {
    int n = sz(r);
    vector<int> alive(n, 1);
    int cnt = n;
    while(cnt > 0) {
        int idx = -1, last = -1;
        For(_, 0, 1) For(i, 0, n - 1) if(alive[i] && r[i] == 0) {
            if(idx < 0 || dist(last, i, n) >= k) idx = i;
            last = i;
        }
        // cerr << idx << "\n";
        // For(i, 0, n - 1) cerr << r[i] << " \n"[i == n - 1];
        For(i, n - k + 1, n - 1) {
            int le = (idx + i) % n;
            if(alive[le]) {
                r[le]--;
                adj[le].eb(idx);
                rev[idx].eb(le);
            } else {
                adj[idx].eb(le);
                rev[le].eb(idx);
            }
        }
        alive[idx] = 0;
        cnt--;
    }
    // memset(vis, 0, sizeof(vis));
    // For(i, 0, n - 1) dp(i);
    owo(adj, 1);
    owo(rev, 2);
}
 
int compare_plants(int x, int y) {
    if(vis[y] & 1) return -1;
    if(vis[y] & 2) return 1;
    return 0;
    // if(tal[y][x]) return 1;
    // if(tal[x][y]) return -1;
    // return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 6 ms 9684 KB Output is correct
3 Incorrect 4 ms 9684 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9648 KB Output is correct
2 Correct 4 ms 9656 KB Output is correct
3 Incorrect 5 ms 9684 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9648 KB Output is correct
2 Correct 4 ms 9656 KB Output is correct
3 Incorrect 5 ms 9684 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 7 ms 9704 KB Output is correct
3 Incorrect 4 ms 9636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9684 KB Output is correct
2 Correct 5 ms 9664 KB Output is correct
3 Correct 4 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 14 ms 10948 KB Output is correct
6 Execution timed out 4014 ms 27780 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 6 ms 9684 KB Output is correct
3 Incorrect 4 ms 9684 KB Output isn't correct
4 Halted 0 ms 0 KB -