답안 #809619

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
809619 2023-08-06T02:37:28 Z PixelCat 식물 비교 (IOI20_plants) C++14
0 / 100
42 ms 4100 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 = 300;
 
vector<int> adj[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 init(int k, vector<int> r) {
    int n = sz(r);
    vector<int> alive(n, 1);
    int cnt = n;
    while(cnt > 0) {
        int idx = -1;
        For(_, 0, 1) For(i, 0, n - 1) if(alive[i]) {
            if(r[i] == 0 && (idx < 0 || dist(idx, i, n) >= k)) idx = i;
        }
        // cerr << idx << "\n";
        // For(i, 0, n - 1) cerr << r[i] << " \n"[i == n - 1];
        For(i, n - k + 1, n - 1) {
            int id = (idx + i) % n;
            if(alive[id]) {
                r[id]--;
                adj[id].eb(idx);
            } else {
                adj[idx].eb(id);
            }
        }
        alive[idx] = 0;
        cnt--;
    }
    memset(vis, 0, sizeof(vis));
    For(i, 0, n - 1) dp(i);
}
 
int compare_plants(int x, int y) {
    if(tal[y][x]) return 1;
    if(tal[x][y]) return -1;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Incorrect 42 ms 4100 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Runtime error 4 ms 656 KB Execution killed with signal 6
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Runtime error 4 ms 656 KB Execution killed with signal 6
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 1 ms 340 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 312 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Incorrect 42 ms 4100 KB Output isn't correct
7 Halted 0 ms 0 KB -