# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1015881 | 2024-07-07T01:43:14 Z | HD1 | 식물 비교 (IOI20_plants) | C++14 | 0 ms | 0 KB |
#include "plants.h" #include<bits/stdc++.h> #define fastio ios_base::sync_with_stdio(0); cin.tie(0); #define sz(x) ll(x.size()) #define all(x) x.begin(), x.end() #define pb push_back #define ff first #define ss second using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll , ll > ii; typedef pair<ii,ll> tri; const ll mod=1e9+7; const ll MAX=1e6; ll A[MAX]; ll n; void init(ll k, std::vector<ll> s) { A[1]=s[0]; n=sz(s); for(int i=2; i<=2*n+1; i++){ A[i]=A[i-1]+s[(i-1)%n]; } return; } ll lock(ll l, ll r){ return A[r]-A[l-1]; } ll compare_plants(ll x, ll y) { if(x<=y){ ll a=lock(x,y-1); if(a==y-x){ return -1; } if(a==0){ return 1; } //cout<<"nel"<<'\n'; x+=n; ll b=lock(y,x-1); if(b==x-y){ return 1; } if(b==0){ return -1; } return 0; } else{ ll a=lock(y,x-1); //cout<<a<<'\n'; if(a==x-y){ return 1; } if(a==0){ return -1; } //cout<<"nel"<<'\n'; y+=n; ll b=lock(x,y-1); //cout<<b<<'\n'; if(b==y-x){ return 1; } if(b==0){ return -1; } return 0; } return 0; }