# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
301013 | luciocf | 식물 비교 (IOI20_plants) | C++14 | 84 ms | 3452 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "plants.h"
using namespace std;
const int maxn = 2e5+10;
int n;
int head[maxn];
int r[maxn];
void init(int k, vector<int> a)
{
n = a.size();
for (int i = 0; i < n; i++)
r[i] = a[i];
head[0] = head[1] = 0;
int at = r[0];
for (int i = 1; i < n-1; i++)
{
if (r[i] == at) head[i+1] = head[i];
else
{
head[i+1] = i;
at = r[i];
}
}
}
int compare_plants(int x, int y)
{
if (min(x, y) != 0 && max(x, y) != n-1)
{
if (x < y && head[y] > x) return 0;
if (x > y && head[x] > y) return 0;
if (x < y)
{
if (r[x] == 0) return 1;
return -1;
}
else
{
if (r[y] == 0) return -1;
return 1;
}
}
if (x == 0)
{
if (head[n-1] <= y)
{
if (r[n-1] == 0 && r[y] == 0) return -1;
if (r[n-1] == 1 && r[y] == 1) return 1;
return 0;
}
else
{
if (head[y] > x) return 0;
if (r[x] == 0) return 1;
return -1;
}
}
else if (y == 0)
{
if (head[n-1] <= x)
{
if (r[n-1] == 0 && r[x] == 0) return 1;
if (r[n-1] == 1 && r[x] == 1) return -1;
return 0;
}
else
{
if (head[x] > y) return 0;
if (r[y] == 0) return -1;
return 1;
}
}
if (x == n-1)
{
if (head[y] <= 0)
{
if (r[n-1] == 0 && r[0] == 0) return 1;
if (r[n-1] == 1 && r[0] == 1) return -1;
return 0;
}
else
{
if (head[x] > y) return 0;
if (r[y] == 0) return -1;
return 1;
}
}
else if (y == n-1)
{
if (head[x] <= 0)
{
if (r[n-1] == 0 && r[0] == 0) return -1;
if (r[n-1] == 1 && r[0] == 1) return 1;
return 0;
}
else
{
if (head[y] > x) return 0;
if (r[x] == 0) return 1;
return -1;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |