Submission #831390

#TimeUsernameProblemLanguageResultExecution timeMemory
831390Dremix10Comparing Plants (IOI20_plants)C++17
5 / 100
75 ms10204 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
const int N = 3e5+5;
const int MOD = 1e9+7;
const ll INF = 1e18+5;
#ifdef dremix
    #define p2(x,y) cerr<<#x<<", "<<#y<<" = "<<x<<", "<<y<<endl;
    #define ppv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v.F<<"-"<<v.S<<", ";cerr<<"}"<<endl;
#else
    #define p2(x,y) {}
    #define ppv(x) {}
#endif


vector<pi> pref;
int n;

void init(int k, vector<int> R) {
    n = R.size();
    
    int i;

    int prev = -1;
    pref.resize(n*2);
    int cnt = 0;
    
    for(i=0;i<n*2;i++){
        if(R[i%n] != prev){
            cnt = 0;
            prev = R[i%n];
        }
        cnt++;
        pref[i] = {cnt,prev};
    }
    ppv(pref)
    return;
}

int compare_plants(int x, int y) {
    int ret = 0;
    

    if(pref[x].F + y - x - 1 == pref[y-1].F){
        if(pref[x].S == 0)ret = 1;
        else ret = -1;
    }

    if(pref[y].F + x + n - 1 - y == pref[x+n-1].F){
        if(pref[y].S == 0)ret = -1;
        else ret = 1;
    }

    return ret;
}
#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...