답안 #300524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300524 2020-09-17T08:43:01 Z Pro100Yan 식물 비교 (IOI20_plants) C++14
5 / 100
110 ms 7544 KB
#include "plants.h"
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int N = 2e5 + 5;
ll pref[2 * N], n;

void init(int k, std::vector<int> r) {
    int l = n = r.size();
    for(int i = 0; i < n; i++)
        pref[i + 1] = pref[i] + r[i];
    for(int i = n; i < 2 * n; i++)
        pref[i + 1] = pref[i] + r[i - n];
	return;
}

int compare_plants(int x, int y) {
    if(pref[y] - pref[x] == y - x)
        return -1;
    else if(pref[x + n] - pref[y] == n + x - y)
        return 1;
    else if(pref[y] - pref[x] == 0)
        return 1;
    else if(pref[x + n] - pref[y] == 0)
        return -1;
	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:13:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   13 |     for(int i = n; i < 2 * n; i++)
      |     ^~~
plants.cpp:15:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   15 |  return;
      |  ^~~~~~
plants.cpp:10:9: warning: unused variable 'l' [-Wunused-variable]
   10 |     int l = n = r.size();
      |         ^
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:25:10: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   25 |     else if(pref[x + n] - pref[y] == 0)
      |          ^~
plants.cpp:27:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   27 |  return 0;
      |  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 63 ms 3320 KB Output is correct
7 Correct 80 ms 3704 KB Output is correct
8 Correct 110 ms 7416 KB Output is correct
9 Correct 107 ms 7416 KB Output is correct
10 Correct 107 ms 7416 KB Output is correct
11 Correct 105 ms 7416 KB Output is correct
12 Correct 108 ms 7544 KB Output is correct
13 Correct 104 ms 7416 KB Output is correct
14 Correct 100 ms 7416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 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 1 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 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 288 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 63 ms 3320 KB Output is correct
7 Correct 80 ms 3704 KB Output is correct
8 Correct 110 ms 7416 KB Output is correct
9 Correct 107 ms 7416 KB Output is correct
10 Correct 107 ms 7416 KB Output is correct
11 Correct 105 ms 7416 KB Output is correct
12 Correct 108 ms 7544 KB Output is correct
13 Correct 104 ms 7416 KB Output is correct
14 Correct 100 ms 7416 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Incorrect 1 ms 384 KB Output isn't correct
18 Halted 0 ms 0 KB -