제출 #589415

#제출 시각아이디문제언어결과실행 시간메모리
589415Lucpp식물 비교 (IOI20_plants)C++17
5 / 100
95 ms9448 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; int n, k; vector<int> dpL, dpR; void init_k2(vector<int> r){ dpL.resize(n), dpR.resize(n); for(int it = 0; it < 2; it++){ for(int i = n-1; i >= 0; i--){ if(r[i]) dpR[i] = dpR[(i+1)%n]+1; } for(int i = 0; i < n; i++){ if(!r[(i+n-1)%n]) dpL[i] = dpL[(i+n-1)%n]+1; } } } void init_else(vector<int> r){ } void init(int K, vector<int> r) { k = K; n = (int)r.size(); if(k == 2) init_k2(r); else init_else(r); } int compare_k2(int x, int y){ int d1 = (y-x+n)%n; int d2 = n-d1; if(dpR[x] >= d1 || dpL[x] >= d2) return -1; if(dpR[y] >= d2 || dpL[y] >= d1) return 1; return 0; } int compare_else(int x, int y){ return 0; } int compare_plants(int x, int y) { if(k == 2) return compare_k2(x, y); else return compare_else(x, y); }
#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...