제출 #421315

#제출 시각아이디문제언어결과실행 시간메모리
421315JUANDI321식물 비교 (IOI20_plants)C++17
0 / 100
1 ms204 KiB
#include "plants.h" #include <vector> #include <iostream> using namespace std; int sumpf[200010], copyr[20010]; int n; void init(int k, vector<int> r) { n = r.size(); sumpf[0] = 200010; //cout<<sumpf[1]<<" "; copyr[0] = r[0]; for(int i = 1; i < r.size(); i++) { sumpf[i] = sumpf[i-1] + r[i-1]; if(r[i-1] == 0) sumpf[i]--; copyr[i] = r[i]; // cout<<sumpf[i+1]<<" "; } //cout<<endl; return; } int compare_plants(int x, int y) { if(x == 0 && y == n-1) { if(copyr[n-1] == 1) return 1; return -1; } int dis = y-x+1; //cout<<dis<<endl; //cout<<sumpf[y]-sumpf[x-1]<<endl; int sum = sumpf[y] - sumpf[x-1]; if(x == 0)sum = sumpf[y]; if(sum == dis) return 1; if(sum == -1 * dis) return -1; if(x>y) { int sb = x; x = y; y = sb; dis = y-x+1; sum = sumpf[y] - sumpf[x-1]; if(x == 0)sum = sumpf[y]; if(sum == dis) return 1; if(sum == -1 * dis) return -1; } return 0; }

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

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  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...