제출 #420396

#제출 시각아이디문제언어결과실행 시간메모리
420396idk321식물 비교 (IOI20_plants)C++17
5 / 100
93 ms8668 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; int k; vector<int> r; vector<int> prefR; int n; int getSum(int from, int to) { int res = prefR[to + 1]; res -= prefR[from]; return res; } void init(int K, std::vector<int> R) { k = K; r = R; n = r.size(); prefR.resize(r.size() + 1); for (int i = 1; i <= r.size(); i++) { prefR[i] = r[i - 1]; prefR[i] += prefR[i - 1]; } return; } int compare_plants(int x, int y) { if (k == 2) { if (getSum(x, y - 1) == (y - x)) return -1; if (getSum(x, y - 1) == 0) return 1; int sum1 = getSum(y, n -1); if (x != 0) sum1 += getSum(0, x - 1); if (sum1 == (n - y) + x) return 1; if (sum1 == 0) return -1; return 0; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 1; i <= r.size(); i++)
      |                     ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...