Submission #388833

# Submission time Handle Problem Language Result Execution time Memory
388833 2021-04-13T06:12:59 Z kshitij_sodani Minerals (JOI19_minerals) C++14
40 / 100
98 ms 6336 KB
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#define endl '\n'

#include "minerals.h"
vector<pair<int,int>> ans;
set<int> xx;
void solve(vector<int> aa,vector<int> bb){

	if(aa.size()==1){
		ans.pb({aa[0],bb[0]});
		return;
	}
	int cur=0;
	vector<int> cc;
	vector<int> dd;
	vector<int> ee;
	vector<int> ff;
	map<int,int> ss;
	map<int,int> tt;
	for(auto j:xx){
		ss[j]++;
	}

	for(int i=0;i<aa.size();i++){
		if(i*2>=aa.size()){
			dd.pb(aa[i]);
			continue;
		}
//		cur=Query(aa[i]);
		cc.pb(aa[i]);
		tt[aa[i]]++;
	}

	for(auto j:tt){
		if(ss.find(j.a)==ss.end()){
			xx.insert(j.a);
			Query(j.a);
		}
	}
	for(auto j:ss){
		if(tt.find(j.a)==tt.end()){
			xx.erase(j.a);
			Query(j.a);
		}
	}
	cur=cc.size();
	for(int i=0;i<bb.size();i++){
		int cur2=Query(bb[i]);
		Query(bb[i]);
		if(cur2==cur){
			ee.pb(bb[i]);
			continue;
		}
		ff.pb(bb[i]);
	}
	
	solve(cc,ee);
	solve(dd,ff);
}
void Solve(int n) {
	vector<int> aa;
	vector<int> bb;
	int cur5=0;
	for(int i=1;i<=2*n;i++){
		int cur2=Query(i);
		if(cur2>cur5){
			aa.pb(i);
			cur5=cur2;
			continue;
		}
		bb.pb(i);
		Query(i);
	}
	for(auto j:aa){
		Query(j);
	}

	solve(aa,bb);

  	for (int i=0; i<n;i++) {
    	Answer(ans[i].a,ans[i].b);
  	}
}

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>)':
minerals.cpp:31:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i=0;i<aa.size();i++){
      |              ~^~~~~~~~~~
minerals.cpp:32:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   if(i*2>=aa.size()){
      |      ~~~^~~~~~~~~~~
minerals.cpp:54:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |  for(int i=0;i<bb.size();i++){
      |              ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 456 KB Output is correct
2 Correct 6 ms 584 KB Output is correct
3 Correct 13 ms 932 KB Output is correct
4 Correct 26 ms 1536 KB Output is correct
5 Correct 54 ms 2632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 3 ms 456 KB Output is correct
6 Correct 6 ms 584 KB Output is correct
7 Correct 13 ms 932 KB Output is correct
8 Correct 26 ms 1536 KB Output is correct
9 Correct 54 ms 2632 KB Output is correct
10 Correct 3 ms 456 KB Output is correct
11 Correct 36 ms 1944 KB Output is correct
12 Correct 56 ms 2712 KB Output is correct
13 Correct 53 ms 2744 KB Output is correct
14 Correct 52 ms 2632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 3 ms 456 KB Output is correct
6 Correct 6 ms 584 KB Output is correct
7 Correct 13 ms 932 KB Output is correct
8 Correct 26 ms 1536 KB Output is correct
9 Correct 54 ms 2632 KB Output is correct
10 Correct 3 ms 456 KB Output is correct
11 Correct 36 ms 1944 KB Output is correct
12 Correct 56 ms 2712 KB Output is correct
13 Correct 53 ms 2744 KB Output is correct
14 Correct 52 ms 2632 KB Output is correct
15 Incorrect 98 ms 6336 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 3 ms 456 KB Output is correct
6 Correct 6 ms 584 KB Output is correct
7 Correct 13 ms 932 KB Output is correct
8 Correct 26 ms 1536 KB Output is correct
9 Correct 54 ms 2632 KB Output is correct
10 Correct 3 ms 456 KB Output is correct
11 Correct 36 ms 1944 KB Output is correct
12 Correct 56 ms 2712 KB Output is correct
13 Correct 53 ms 2744 KB Output is correct
14 Correct 52 ms 2632 KB Output is correct
15 Incorrect 98 ms 6336 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 3 ms 456 KB Output is correct
6 Correct 6 ms 584 KB Output is correct
7 Correct 13 ms 932 KB Output is correct
8 Correct 26 ms 1536 KB Output is correct
9 Correct 54 ms 2632 KB Output is correct
10 Correct 3 ms 456 KB Output is correct
11 Correct 36 ms 1944 KB Output is correct
12 Correct 56 ms 2712 KB Output is correct
13 Correct 53 ms 2744 KB Output is correct
14 Correct 52 ms 2632 KB Output is correct
15 Incorrect 98 ms 6336 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 3 ms 456 KB Output is correct
6 Correct 6 ms 584 KB Output is correct
7 Correct 13 ms 932 KB Output is correct
8 Correct 26 ms 1536 KB Output is correct
9 Correct 54 ms 2632 KB Output is correct
10 Correct 3 ms 456 KB Output is correct
11 Correct 36 ms 1944 KB Output is correct
12 Correct 56 ms 2712 KB Output is correct
13 Correct 53 ms 2744 KB Output is correct
14 Correct 52 ms 2632 KB Output is correct
15 Incorrect 98 ms 6336 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 3 ms 456 KB Output is correct
6 Correct 6 ms 584 KB Output is correct
7 Correct 13 ms 932 KB Output is correct
8 Correct 26 ms 1536 KB Output is correct
9 Correct 54 ms 2632 KB Output is correct
10 Correct 3 ms 456 KB Output is correct
11 Correct 36 ms 1944 KB Output is correct
12 Correct 56 ms 2712 KB Output is correct
13 Correct 53 ms 2744 KB Output is correct
14 Correct 52 ms 2632 KB Output is correct
15 Incorrect 98 ms 6336 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 3 ms 456 KB Output is correct
6 Correct 6 ms 584 KB Output is correct
7 Correct 13 ms 932 KB Output is correct
8 Correct 26 ms 1536 KB Output is correct
9 Correct 54 ms 2632 KB Output is correct
10 Correct 3 ms 456 KB Output is correct
11 Correct 36 ms 1944 KB Output is correct
12 Correct 56 ms 2712 KB Output is correct
13 Correct 53 ms 2744 KB Output is correct
14 Correct 52 ms 2632 KB Output is correct
15 Incorrect 98 ms 6336 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -