Submission #795992

# Submission time Handle Problem Language Result Execution time Memory
795992 2023-07-28T03:24:18 Z boyliguanhan Comparing Plants (IOI20_plants) C++17
5 / 100
66 ms 11092 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
#define N 200100
int n;
int pos[N], loc[N], cnt;
deque<int> R;
int info[200100][2];
void init2(vector<int> r) {
    R.resize(n=r.size());
    iota(R.begin(), R.end(), 0);
    for(int i = 0; i < n; i++)
        if(r[R.front()] == r[R.back()])
            R.push_back(R.front()),R.pop_front();
        else 
            break;
    for(int i = 0; i < n; i++)
        loc[R[i]] = i;
    info[R.front()][0] = 0;
    info[R.front()][1] = r[R.front()];
    int prev = R.front();
    R.pop_front();
    for(int i = 1; i < n; i++) {
        info[R.front()][1] = r[R.front()];
        if(r[R.front()]!=r[prev]) {
            info[R.front()][0] = ++cnt;
        } else {
            info[R.front()][0] = info[prev][0];
        }
        prev = R.front();
        R.pop_front();
    }
	return;
}
void init(int k, vector<int> r) {
    int x = k;
    x = x+1;
    init2(r);
}
int compare_plants(int x, int y) {
    bool ans2=0;
    if(loc[x]>loc[y])
        ans2=1,swap(x,y);
    if(loc[x]==0)
        if(info[y][0]==info[n-1][0])
            ans2^=1,swap(x,y);
    bool a = info[x][0] == info[y?y-1:n-1][0];
	if(!a)
        return 0;
    return (ans2^info[x][1]?-1:1);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 38 ms 3060 KB Output is correct
7 Correct 43 ms 5748 KB Output is correct
8 Correct 57 ms 11092 KB Output is correct
9 Correct 56 ms 11004 KB Output is correct
10 Correct 66 ms 11000 KB Output is correct
11 Correct 57 ms 10984 KB Output is correct
12 Correct 57 ms 11000 KB Output is correct
13 Correct 55 ms 10972 KB Output is correct
14 Correct 55 ms 11004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 38 ms 3060 KB Output is correct
7 Correct 43 ms 5748 KB Output is correct
8 Correct 57 ms 11092 KB Output is correct
9 Correct 56 ms 11004 KB Output is correct
10 Correct 66 ms 11000 KB Output is correct
11 Correct 57 ms 10984 KB Output is correct
12 Correct 57 ms 11000 KB Output is correct
13 Correct 55 ms 10972 KB Output is correct
14 Correct 55 ms 11004 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Incorrect 0 ms 212 KB Output isn't correct
18 Halted 0 ms 0 KB -