답안 #487913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
487913 2021-11-17T03:51:20 Z i_am_noob Minerals (JOI19_minerals) C++17
85 / 100
51 ms 7956 KB
#include "minerals.h"

#pragma GCC target("avx2")
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
using namespace std;

#define ll long long
//#define int ll
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define inf 1010000000
//#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#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(...) 826
#endif

const int maxn=43005;

int x,out_id[2][maxn];
bool a[2][maxn];

inline bool query(int id1, int id2){
	int y=Query(out_id[id1][id2]);
	a[id1][id2]^=1;
	bool flag=x!=y;
	x=y;
	return flag;
}

void Solve(int n){
	x=0;
	int cur1=0,cur2=0;
	rep(2*n){
		int y=Query(i+1);
		if(y>x){
			out_id[0][cur1++]=i+1;
		}
		else{
			out_id[1][cur2++]=i+1;
		}
		x=y;
	}
	assert(cur1==n&&cur2==n);
	rep(n) a[0][i]=1;
	vector<vector<int>> vec;
	vec.pb({});
	rep(n) vec.back().pb(i);
	rep1(_,16){
		if(sz(vec)==n) break;
		int cur=0;
		for(auto& vv: vec){
			int s=sz(vv)/2;
			if(sz(vv)>1){
				rep(sz(vv)){
					if(i<s&&!a[1][cur+i]) query(1,cur+i);
					if(i>=s&&a[1][cur+i]) query(1,cur+i);
				}
			}
			cur+=sz(vv);
		}
		assert(cur==n);
		vector<vector<int>> nvec;
		for(auto& vv: vec){
			if(sz(vv)==1){
				nvec.pb(vv);
				continue;
			}
			bool good[sz(vv)];
			memset(good,0,sizeof good);
			nvec.pb({});
			rep(sz(vv)-1){
				good[i]=query(0,vv[i]);
				if(good[i]) nvec.back().pb(vv[i]);
			}
			if(count(good,good+sz(vv),1)!=sz(vv)/2){
				good[sz(vv)-1]=1;
				nvec.back().pb(vv.back());
			}
			assert(sz(nvec.back())==sz(vv)/2);
			nvec.pb({});
			rep(sz(vv)) if(!good[i]) nvec.back().pb(vv[i]);
			assert(sz(nvec.back())==sz(vv)-sz(vv)/2);
		}
		vec=nvec;
	}
	assert(sz(vec)==n);
	rep(n){
		Answer(out_id[1][i],out_id[0][vec[i][0]]);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 456 KB Output is correct
2 Correct 2 ms 584 KB Output is correct
3 Correct 3 ms 968 KB Output is correct
4 Correct 9 ms 1608 KB Output is correct
5 Correct 15 ms 2900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 3 ms 968 KB Output is correct
8 Correct 9 ms 1608 KB Output is correct
9 Correct 15 ms 2900 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 14 ms 2164 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 12 ms 2944 KB Output is correct
14 Correct 11 ms 2840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 3 ms 968 KB Output is correct
8 Correct 9 ms 1608 KB Output is correct
9 Correct 15 ms 2900 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 14 ms 2164 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 12 ms 2944 KB Output is correct
14 Correct 11 ms 2840 KB Output is correct
15 Correct 45 ms 7700 KB Output is correct
16 Correct 48 ms 7564 KB Output is correct
17 Correct 38 ms 7532 KB Output is correct
18 Correct 40 ms 7432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 3 ms 968 KB Output is correct
8 Correct 9 ms 1608 KB Output is correct
9 Correct 15 ms 2900 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 14 ms 2164 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 12 ms 2944 KB Output is correct
14 Correct 11 ms 2840 KB Output is correct
15 Correct 45 ms 7700 KB Output is correct
16 Correct 48 ms 7564 KB Output is correct
17 Correct 38 ms 7532 KB Output is correct
18 Correct 40 ms 7432 KB Output is correct
19 Correct 51 ms 7700 KB Output is correct
20 Correct 47 ms 7684 KB Output is correct
21 Correct 34 ms 7740 KB Output is correct
22 Correct 35 ms 7624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 3 ms 968 KB Output is correct
8 Correct 9 ms 1608 KB Output is correct
9 Correct 15 ms 2900 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 14 ms 2164 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 12 ms 2944 KB Output is correct
14 Correct 11 ms 2840 KB Output is correct
15 Correct 45 ms 7700 KB Output is correct
16 Correct 48 ms 7564 KB Output is correct
17 Correct 38 ms 7532 KB Output is correct
18 Correct 40 ms 7432 KB Output is correct
19 Correct 51 ms 7700 KB Output is correct
20 Correct 47 ms 7684 KB Output is correct
21 Correct 34 ms 7740 KB Output is correct
22 Correct 35 ms 7624 KB Output is correct
23 Correct 48 ms 7836 KB Output is correct
24 Correct 48 ms 7820 KB Output is correct
25 Correct 34 ms 7824 KB Output is correct
26 Correct 34 ms 7644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 3 ms 968 KB Output is correct
8 Correct 9 ms 1608 KB Output is correct
9 Correct 15 ms 2900 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 14 ms 2164 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 12 ms 2944 KB Output is correct
14 Correct 11 ms 2840 KB Output is correct
15 Correct 45 ms 7700 KB Output is correct
16 Correct 48 ms 7564 KB Output is correct
17 Correct 38 ms 7532 KB Output is correct
18 Correct 40 ms 7432 KB Output is correct
19 Correct 51 ms 7700 KB Output is correct
20 Correct 47 ms 7684 KB Output is correct
21 Correct 34 ms 7740 KB Output is correct
22 Correct 35 ms 7624 KB Output is correct
23 Correct 48 ms 7836 KB Output is correct
24 Correct 48 ms 7820 KB Output is correct
25 Correct 34 ms 7824 KB Output is correct
26 Correct 34 ms 7644 KB Output is correct
27 Correct 50 ms 7956 KB Output is correct
28 Correct 49 ms 7940 KB Output is correct
29 Correct 35 ms 7956 KB Output is correct
30 Correct 36 ms 7812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 3 ms 968 KB Output is correct
8 Correct 9 ms 1608 KB Output is correct
9 Correct 15 ms 2900 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 14 ms 2164 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 12 ms 2944 KB Output is correct
14 Correct 11 ms 2840 KB Output is correct
15 Correct 45 ms 7700 KB Output is correct
16 Correct 48 ms 7564 KB Output is correct
17 Correct 38 ms 7532 KB Output is correct
18 Correct 40 ms 7432 KB Output is correct
19 Correct 51 ms 7700 KB Output is correct
20 Correct 47 ms 7684 KB Output is correct
21 Correct 34 ms 7740 KB Output is correct
22 Correct 35 ms 7624 KB Output is correct
23 Correct 48 ms 7836 KB Output is correct
24 Correct 48 ms 7820 KB Output is correct
25 Correct 34 ms 7824 KB Output is correct
26 Correct 34 ms 7644 KB Output is correct
27 Correct 50 ms 7956 KB Output is correct
28 Correct 49 ms 7940 KB Output is correct
29 Correct 35 ms 7956 KB Output is correct
30 Correct 36 ms 7812 KB Output is correct
31 Incorrect 46 ms 6284 KB Wrong Answer [2]
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 3 ms 968 KB Output is correct
8 Correct 9 ms 1608 KB Output is correct
9 Correct 15 ms 2900 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 14 ms 2164 KB Output is correct
12 Correct 15 ms 2856 KB Output is correct
13 Correct 12 ms 2944 KB Output is correct
14 Correct 11 ms 2840 KB Output is correct
15 Correct 45 ms 7700 KB Output is correct
16 Correct 48 ms 7564 KB Output is correct
17 Correct 38 ms 7532 KB Output is correct
18 Correct 40 ms 7432 KB Output is correct
19 Correct 51 ms 7700 KB Output is correct
20 Correct 47 ms 7684 KB Output is correct
21 Correct 34 ms 7740 KB Output is correct
22 Correct 35 ms 7624 KB Output is correct
23 Correct 48 ms 7836 KB Output is correct
24 Correct 48 ms 7820 KB Output is correct
25 Correct 34 ms 7824 KB Output is correct
26 Correct 34 ms 7644 KB Output is correct
27 Correct 50 ms 7956 KB Output is correct
28 Correct 49 ms 7940 KB Output is correct
29 Correct 35 ms 7956 KB Output is correct
30 Correct 36 ms 7812 KB Output is correct
31 Incorrect 46 ms 6284 KB Wrong Answer [2]
32 Halted 0 ms 0 KB -