답안 #805668

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
805668 2023-08-03T19:48:42 Z Jkap 식물 비교 (IOI20_plants) C++14
0 / 100
1 ms 308 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, 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) {
        out = 1-ri[a];
    }
    else if (di[b] < b && di[b] >=a) {
        out = 1-ri[b];
    }
    if (out == -1) {
        return 0;
    }
    if (y==a) {
        out = 1-out;
    }
    if (out == 0) {
        out --;
    }
    return out;
    
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:11:7: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   11 |   int x, n = r.size();
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 304 KB Output isn't correct
3 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 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 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 308 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 304 KB Output isn't correct
3 Halted 0 ms 0 KB -