답안 #805682

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
805682 2023-08-03T20:18:18 Z Jkap 식물 비교 (IOI20_plants) C++14
5 / 100
59 ms 8680 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define si unordered_set<int>
#define vi vector<int>

int di[200005];
int ri[200005];

void init(int k, vi r) {
  int x=0;
  int n = r.size();

  for (int i=n-1; i>=0; i--) {
    if (r[i] != r[n-1]) {
      x = i+1;
      break;
    }
  }
  int curr = x;
  for (int i=x+n-1; i>=x; i--) {
    if (r[i%n] == r[curr]) {
      curr = (i+1) %n;
    }
    di[i%n] = curr;
    ri[i%n] = r[i%n];
  }
  
}

int compare_plants(int x, int y) {
    int a = min(x, y), b = max(x, y), out=-1;
    if (di[a] >= b || di[a] < a) {
        out = 1-ri[a];
    }
    else if (di[b] < b && di[b] >=a) {
        out = ri[b];
    }
    if (out == -1) {
        return 0;
    }
    if (y==a) {
        out = 1-out;
    }
    if (out == 0) {
        out --;
    }
    return out;
    
}
# 결과 실행 시간 메모리 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 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 39 ms 3172 KB Output is correct
7 Correct 43 ms 3384 KB Output is correct
8 Correct 59 ms 8652 KB Output is correct
9 Correct 59 ms 8668 KB Output is correct
10 Correct 58 ms 8668 KB Output is correct
11 Correct 57 ms 8680 KB Output is correct
12 Correct 58 ms 8652 KB Output is correct
13 Correct 55 ms 8680 KB Output is correct
14 Correct 56 ms 8680 KB Output is correct
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 39 ms 3172 KB Output is correct
7 Correct 43 ms 3384 KB Output is correct
8 Correct 59 ms 8652 KB Output is correct
9 Correct 59 ms 8668 KB Output is correct
10 Correct 58 ms 8668 KB Output is correct
11 Correct 57 ms 8680 KB Output is correct
12 Correct 58 ms 8652 KB Output is correct
13 Correct 55 ms 8680 KB Output is correct
14 Correct 56 ms 8680 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 -