답안 #313221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
313221 2020-10-15T14:22:44 Z DanerZein 식물 비교 (IOI20_plants) C++14
0 / 100
4000 ms 5488 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
vi ra;
int n;
void init(int k, std::vector<int> r) {
  int t=r.size();
  for(int i=0;i<t;i++) ra.push_back(r[i]);
  n=r.size();
  return;
}

int compare_plants(int x, int y) {
  int o1,o2;
  o1=ra[x]; o2=ra[y];
  int l1,l2;
  l2=((x-1)+n)%n;
  l1=((y-1)+n)%n;
  int i=x;
  while(true){
    if(o1!=ra[i]){
      o1=-1;
      break;
    }
    if(i==l1) break;
    i++;
    i%=n;
  }
  i=y;
  while(true){
    if(o2!=ra[i]){
      o2=-1;
      break;
    }
    if(i==l2) break;
    i++;
    i%=n;
  }
  //cout<<o1<<" "<<o2<<" "<<l1<<" "<<l2<<" "<<ra[y]<<" "<<ra[x]<<endl;
  if(o1==o2 and o1==-1){
    return 0;
  }
  if(o1!=-1){
    if(o1==1) return -1;
    else return 1;
  }
  if(o2!=-1){
    if(o2==1) return 1;
    else return -1;
  }
}

Compilation message

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 71 ms 3192 KB Output is correct
7 Correct 290 ms 3380 KB Output is correct
8 Correct 131 ms 5488 KB Output is correct
9 Correct 307 ms 5360 KB Output is correct
10 Correct 1900 ms 5360 KB Output is correct
11 Execution timed out 4056 ms 5360 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 1 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 71 ms 3192 KB Output is correct
7 Correct 290 ms 3380 KB Output is correct
8 Correct 131 ms 5488 KB Output is correct
9 Correct 307 ms 5360 KB Output is correct
10 Correct 1900 ms 5360 KB Output is correct
11 Execution timed out 4056 ms 5360 KB Time limit exceeded
12 Halted 0 ms 0 KB -