답안 #833918

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
833918 2023-08-22T09:29:33 Z finn__ 식물 비교 (IOI20_plants) C++17
5 / 100
74 ms 7920 KB
#include <bits/stdc++.h>

#include "plants.h"

using namespace std;

constexpr size_t N = 200000;

size_t n;
int subtask, s[N];

void init(int k, std::vector<int> r)
{
    n = r.size();
    if (k == 2)
        subtask = 1;
    else
        subtask = 3;

    if (subtask == 1)
    {
        partial_sum(r.begin(), r.end(), s);
    }
    else
    {
    }
}

int compare_plants(int x, int y)
{
    if (subtask == 1)
    {
        int z = s[y - 1] - (x ? s[x - 1] : 0);
        return !z ? 1 : (z == y - x ? -1 : (!(s[n - 1] - z) ? -1 : ((s[n - 1] - z == n - (y - x) ? 1 : 0))));
    }
}

Compilation message

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:34:83: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         return !z ? 1 : (z == y - x ? -1 : (!(s[n - 1] - z) ? -1 : ((s[n - 1] - z == n - (y - x) ? 1 : 0))));
      |                                                                      ~~~~~~~~~~~~~^~~~~~~~~~~~~~
plants.cpp:36:1: warning: control reaches end of non-void function [-Wreturn-type]
   36 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 4056 KB Output is correct
7 Correct 46 ms 5408 KB Output is correct
8 Correct 55 ms 7788 KB Output is correct
9 Correct 54 ms 7900 KB Output is correct
10 Correct 55 ms 7896 KB Output is correct
11 Correct 57 ms 7916 KB Output is correct
12 Correct 55 ms 7880 KB Output is correct
13 Correct 72 ms 7908 KB Output is correct
14 Correct 74 ms 7920 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 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 1 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 316 KB Output is correct
2 Correct 0 ms 308 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 4056 KB Output is correct
7 Correct 46 ms 5408 KB Output is correct
8 Correct 55 ms 7788 KB Output is correct
9 Correct 54 ms 7900 KB Output is correct
10 Correct 55 ms 7896 KB Output is correct
11 Correct 57 ms 7916 KB Output is correct
12 Correct 55 ms 7880 KB Output is correct
13 Correct 72 ms 7908 KB Output is correct
14 Correct 74 ms 7920 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 -