Submission #532912

# Submission time Handle Problem Language Result Execution time Memory
532912 2022-03-04T08:24:26 Z Koosha_mv Minerals (JOI19_minerals) C++14
75 / 100
44 ms 3332 KB
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#include "minerals.h"

const int N=2e5+99;

int n,last,s[N],t[N],L[N],R[N],mark[N];
vector<pair<int,int>> Ans;
vector<int> pos,A,B;
/*
void Answer(int a, int b){
	cout<<a<<" edge "<<b<<endl;
}
int Query(int x){
	int res=0;
	f(i,1,n+1) if(mark[s[i]] || mark[t[i]]) res++;
	cout<<"? "<<x<<" "<<res<<endl;
	return res;
}*/
bool ask(int x){
	mark[x]^=1;
	int p=Query(x),res=(p!=last);
	last=p;
	return res;
}
void reset(){
	f(i,1,2*n+1) ask(i);
}
void get(int l,int r){
	for(auto x : pos){
		if(x<l || r<=x){
			ask(B[x]);
		} 
	} 
	pos.clear();
	f(i,l,r){
		pos.pb(i);
		if(!mark[B[i]]) ask(B[i]);
	}
}
void solve(int l,int r,vector<int> &vec){
	if(l+1==r){
		Ans.pb({vec[0],B[l]});
		return ;
	}
	vector<int> a,b;
	int mid=(l+r+1)>>1;
	get(l,mid);
	for(auto x : vec){
		if(ask(x)==0) a.pb(x);
		else b.pb(x);
	}
	solve(l,mid,a);
	solve(mid,r,b);
}
void Solve(int N){
	n=N;
	f(i,1,2*n+1){
		if(ask(i)) A.pb(i);
		else B.pb(i);
	}
	f(i,0,n) pos.pb(i);
	solve(0,n,A);
	for(auto p : Ans){
		Answer(p.F,p.S);
	}
}
/*
4
1 4
2 5
3 6
7 8
*/
/*
main(){
	int n;
	cin>>n;
	f(i,1,n+1){
		cin>>s[i]>>t[i];
	}
	Solve(n);
}
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 3 ms 584 KB Output is correct
4 Correct 8 ms 932 KB Output is correct
5 Correct 11 ms 1336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 584 KB Output is correct
8 Correct 8 ms 932 KB Output is correct
9 Correct 11 ms 1336 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1088 KB Output is correct
12 Correct 12 ms 1352 KB Output is correct
13 Correct 15 ms 1344 KB Output is correct
14 Correct 9 ms 1404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 584 KB Output is correct
8 Correct 8 ms 932 KB Output is correct
9 Correct 11 ms 1336 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1088 KB Output is correct
12 Correct 12 ms 1352 KB Output is correct
13 Correct 15 ms 1344 KB Output is correct
14 Correct 9 ms 1404 KB Output is correct
15 Correct 31 ms 3044 KB Output is correct
16 Correct 44 ms 3088 KB Output is correct
17 Correct 24 ms 3076 KB Output is correct
18 Correct 31 ms 3008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 584 KB Output is correct
8 Correct 8 ms 932 KB Output is correct
9 Correct 11 ms 1336 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1088 KB Output is correct
12 Correct 12 ms 1352 KB Output is correct
13 Correct 15 ms 1344 KB Output is correct
14 Correct 9 ms 1404 KB Output is correct
15 Correct 31 ms 3044 KB Output is correct
16 Correct 44 ms 3088 KB Output is correct
17 Correct 24 ms 3076 KB Output is correct
18 Correct 31 ms 3008 KB Output is correct
19 Correct 33 ms 3052 KB Output is correct
20 Correct 43 ms 3040 KB Output is correct
21 Correct 26 ms 3332 KB Output is correct
22 Correct 30 ms 3092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 584 KB Output is correct
8 Correct 8 ms 932 KB Output is correct
9 Correct 11 ms 1336 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1088 KB Output is correct
12 Correct 12 ms 1352 KB Output is correct
13 Correct 15 ms 1344 KB Output is correct
14 Correct 9 ms 1404 KB Output is correct
15 Correct 31 ms 3044 KB Output is correct
16 Correct 44 ms 3088 KB Output is correct
17 Correct 24 ms 3076 KB Output is correct
18 Correct 31 ms 3008 KB Output is correct
19 Correct 33 ms 3052 KB Output is correct
20 Correct 43 ms 3040 KB Output is correct
21 Correct 26 ms 3332 KB Output is correct
22 Correct 30 ms 3092 KB Output is correct
23 Incorrect 36 ms 3104 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 584 KB Output is correct
8 Correct 8 ms 932 KB Output is correct
9 Correct 11 ms 1336 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1088 KB Output is correct
12 Correct 12 ms 1352 KB Output is correct
13 Correct 15 ms 1344 KB Output is correct
14 Correct 9 ms 1404 KB Output is correct
15 Correct 31 ms 3044 KB Output is correct
16 Correct 44 ms 3088 KB Output is correct
17 Correct 24 ms 3076 KB Output is correct
18 Correct 31 ms 3008 KB Output is correct
19 Correct 33 ms 3052 KB Output is correct
20 Correct 43 ms 3040 KB Output is correct
21 Correct 26 ms 3332 KB Output is correct
22 Correct 30 ms 3092 KB Output is correct
23 Incorrect 36 ms 3104 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 584 KB Output is correct
8 Correct 8 ms 932 KB Output is correct
9 Correct 11 ms 1336 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1088 KB Output is correct
12 Correct 12 ms 1352 KB Output is correct
13 Correct 15 ms 1344 KB Output is correct
14 Correct 9 ms 1404 KB Output is correct
15 Correct 31 ms 3044 KB Output is correct
16 Correct 44 ms 3088 KB Output is correct
17 Correct 24 ms 3076 KB Output is correct
18 Correct 31 ms 3008 KB Output is correct
19 Correct 33 ms 3052 KB Output is correct
20 Correct 43 ms 3040 KB Output is correct
21 Correct 26 ms 3332 KB Output is correct
22 Correct 30 ms 3092 KB Output is correct
23 Incorrect 36 ms 3104 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 3 ms 584 KB Output is correct
8 Correct 8 ms 932 KB Output is correct
9 Correct 11 ms 1336 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1088 KB Output is correct
12 Correct 12 ms 1352 KB Output is correct
13 Correct 15 ms 1344 KB Output is correct
14 Correct 9 ms 1404 KB Output is correct
15 Correct 31 ms 3044 KB Output is correct
16 Correct 44 ms 3088 KB Output is correct
17 Correct 24 ms 3076 KB Output is correct
18 Correct 31 ms 3008 KB Output is correct
19 Correct 33 ms 3052 KB Output is correct
20 Correct 43 ms 3040 KB Output is correct
21 Correct 26 ms 3332 KB Output is correct
22 Correct 30 ms 3092 KB Output is correct
23 Incorrect 36 ms 3104 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -