답안 #385932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
385932 2021-04-05T09:00:16 Z i_am_noob 식물 비교 (IOI20_plants) C++17
0 / 100
4000 ms 6356 KB
#include<bits/stdc++.h>
#include "plants.h"
using namespace std;

#define ll long long
//#define int ll
#define rep(n) rep1(i,n)
#define rep1(i,n) rep2(i,0,n)
#define rep2(i,a,b) for(int i=a; i<(b); ++i)
#define rep3(i,a,b) for(int i=a; i>=(b); --i)
#define pb push_back
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define inf 0x3f3f3f3f3f3f3f3f
#define pow2(x) (1ll<<(x))

#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << " " << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T x){cerr << x << endl;}
template<typename T, typename ...S> void _do(T x, S... y){cerr << x << ", ";_do(y...);}
#else
#define bug(...) 49
#endif

const int maxn=200005;

int n,k,sum[maxn],a[maxn],minn[4*maxn],minid[4*maxn];
vector<int> r;


void init(int _k, vector<int> _r){
    k=_k;
    r=_r;
    n=sz(r);
    rep(n) sum[i+1]=sum[i]+r[i];
    rep3(i,n-1,0){
    	rep1(j,n) if(r[j]==0){
    		a[j]=i;
    		rep1(ii,k-1) r[(j-ii-1+n)%n]--;
    		r[j]=n;
    		break;
    	}
    }
}

int compare_plants(int x, int y) {
    if(k==2){
        if(sum[y]-sum[x]==y-x) return -1;
        if(sum[y]-sum[x]==0) return 1;
        if(sum[n]-sum[y]+sum[x]==n-y+x) return 1;
        if(sum[n]-sum[y]+sum[x]==0) return -1;
        return 0;
    }
    return a[x]>a[y]?1:-1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 63 ms 3180 KB Output is correct
7 Correct 281 ms 3564 KB Output is correct
8 Execution timed out 4073 ms 6356 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 83 ms 4924 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 63 ms 3180 KB Output is correct
7 Correct 281 ms 3564 KB Output is correct
8 Execution timed out 4073 ms 6356 KB Time limit exceeded
9 Halted 0 ms 0 KB -