답안 #385942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
385942 2021-04-05T09:11:35 Z i_am_noob 식물 비교 (IOI20_plants) C++17
0 / 100
2 ms 492 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];
    if(n<5005){
    	bool flag;
	    rep3(i,n-1,0){
	    	flag=0;
	    	rep1(j,n) if(r[j]==0){
	    		a[j]=i;
	    		rep1(ii,k-1) r[(j-ii-1+n)%n]--;
	    		r[j]=n;
	    		flag=1;
	    		break;
	    	}
	    	assert(flag);
	    }
	}
}

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 Runtime error 2 ms 492 KB Execution killed with signal 6
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 Runtime error 2 ms 492 KB Execution killed with signal 6
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 Runtime error 2 ms 492 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 2 ms 492 KB Execution killed with signal 6
3 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 Runtime error 2 ms 492 KB Execution killed with signal 6
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 Runtime error 2 ms 492 KB Execution killed with signal 6
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 Runtime error 2 ms 492 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -