답안 #133266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
133266 2019-07-20T10:23:54 Z hamzqq9 Minerals (JOI19_minerals) C++14
6 / 100
30 ms 2412 KB
#include "minerals.h"
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ii pair<int,int>
#define ll long long
#define orta ((bas+son)>>1)
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define inf 2000000000000000
#define N 500005
#define MOD 998244353
#define KOK 700		
using namespace std;

void Solve(int n) {

	n<<=1;

	mt19937 rnd(time(NULL));

	vector<int> p;
	vector<int> gr(n);
	vector<ii> qu(n);
	vector<vector<int>> ask(n);
	vector<int> A,B;
	vector<int> on(n,0);

	for(int i=1;i<=n;i++) p.pb(i);

	shuffle(p.begin(),p.end(),rnd);

	int cnt=0;
	
	for(int i=0;i<n;i++) {

		int cur=Query(p[i]);

		if(cur>cnt) {

			gr[i]=0;
			A.pb(i);
			
		}
		else {

			gr[i]=1;

			qu[i]={0,sz(A)-1};
			ask[(qu[i].st+qu[i].nd)>>1].pb(i);

			B.pb(i);

		}

		cnt=cur;

	}

	// values in vectors are just indices not permuation values

	while(1) {

		bool flag2=1;

		for(int t=1;t<=2;t++) {

				//cerr<<t<<"\n";
			if(t==1) {


				for(int i=sz(A)-1;i>=0;i--) {

					for(auto x:ask[i]) {

						//cerr<<i<<" "<<x<<"\n";

						int cur=Query(p[x]);

						if(cur!=cnt) {

							qu[x].st=i+1;

						}
						else {

							qu[x].nd=i;

						}

						cnt=cur;

						if(qu[x].st!=qu[x].nd) ask[(qu[x].st+qu[x].nd)>>1].pb(x);

					}

					ask[i].clear();

					cnt=Query(p[A[i]]);

				}

			}
			else {

				for(int i=0;i<sz(A);i++) {

					cnt=Query(p[A[i]]);

					for(auto x:ask[i]) {

					//	cerr<<i<<" "<<x<<"\n";
						int cur=Query(p[x]);

						if(cur!=cnt) {

							qu[x].st=i+1;

						}
						else {

							qu[x].nd=i;

						}

						cnt=cur;

						if(qu[x].st!=qu[x].nd) ask[(qu[x].st+qu[x].nd)>>1].pb(x);

					}

				}

			}

			bool flag=0;

			for(int i=0;i<sz(A);i++) flag|=(sz(ask[i])>0);

			if(!flag) {flag2=0;break ;}

		}

		if(!flag2) break ;
	
	}

	for(int i:B) {

		int pos=qu[i].st;

		Answer(p[A[pos]],p[i]);

	}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 632 KB Output is correct
2 Correct 15 ms 1016 KB Output is correct
3 Incorrect 30 ms 2412 KB Wrong Answer [2]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 15 ms 1016 KB Output is correct
7 Incorrect 30 ms 2412 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 15 ms 1016 KB Output is correct
7 Incorrect 30 ms 2412 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 15 ms 1016 KB Output is correct
7 Incorrect 30 ms 2412 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 15 ms 1016 KB Output is correct
7 Incorrect 30 ms 2412 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 15 ms 1016 KB Output is correct
7 Incorrect 30 ms 2412 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 15 ms 1016 KB Output is correct
7 Incorrect 30 ms 2412 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 15 ms 1016 KB Output is correct
7 Incorrect 30 ms 2412 KB Wrong Answer [2]
8 Halted 0 ms 0 KB -