Submission #112586

# Submission time Handle Problem Language Result Execution time Memory
112586 2019-05-20T18:01:58 Z reality Minerals (JOI19_minerals) C++17
40 / 100
38 ms 3444 KB
#include "minerals.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}

const int N = 1e5 + 5;

int was[N];

void Go(vi a,vi b) {
	if (a.size() == 1) {
		Answer(a[0],b[0]);
	} else {
		int sz = a.size();
		int m = sz / 2;
		int cnt;
		for (int i = 0;i < m;++i)
			cnt = Query(a[i]),was[a[i]] ^= 1;
		vi x1(a.begin(),a.begin() + m),y1,x2(a.begin() + m,a.end()),y2;
		int h = was[a[0]];
		for (int i = 0;i < sz;++i) {
			if (h) {
				int cur = Query(b[i]);
				was[b[i]] ^= 1;
				if (cnt + 1 == cur) {
					y2.pb(b[i]);
					Query(b[i]);
					was[b[i]] ^= 1;
				} else {
					y1.pb(b[i]);
				}
			} else {
				int cur = Query(b[i]);
				was[b[i]] ^= 1;
				if (cnt == cur) {
					y2.pb(b[i]);
					Query(b[i]);
					was[b[i]] ^= 1;
				} else {
					y1.pb(b[i]);
					cnt = cur;
				}
			}
		}
		Go(x1,y1);
		Go(x2,y2);
	}
}

void Solve(int N) {
  	vi a,b;
  	int cnt = 0;
  	for (int i = 1;i <= 2 * N;++i) {
  		int cur = Query(i);
  		if (cnt + 1 == cur) {
  			a.pb(i);
  		} else {
  			b.pb(i);
  		}
  		was[i] = 1;
  		cnt = cur;
  	}
  	Go(a,b);
}

Compilation message

minerals.cpp: In function 'void Go(std::vector<int>, std::vector<int>)':
minerals.cpp:50:5: warning: 'cnt' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (cnt == cur) {
     ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 640 KB Output is correct
3 Correct 5 ms 636 KB Output is correct
4 Correct 9 ms 896 KB Output is correct
5 Correct 17 ms 1452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 5 ms 636 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 17 ms 1452 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 1152 KB Output is correct
12 Correct 16 ms 1452 KB Output is correct
13 Correct 14 ms 1460 KB Output is correct
14 Correct 14 ms 1456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 5 ms 636 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 17 ms 1452 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 1152 KB Output is correct
12 Correct 16 ms 1452 KB Output is correct
13 Correct 14 ms 1460 KB Output is correct
14 Correct 14 ms 1456 KB Output is correct
15 Incorrect 38 ms 3444 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 5 ms 636 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 17 ms 1452 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 1152 KB Output is correct
12 Correct 16 ms 1452 KB Output is correct
13 Correct 14 ms 1460 KB Output is correct
14 Correct 14 ms 1456 KB Output is correct
15 Incorrect 38 ms 3444 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 5 ms 636 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 17 ms 1452 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 1152 KB Output is correct
12 Correct 16 ms 1452 KB Output is correct
13 Correct 14 ms 1460 KB Output is correct
14 Correct 14 ms 1456 KB Output is correct
15 Incorrect 38 ms 3444 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 5 ms 636 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 17 ms 1452 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 1152 KB Output is correct
12 Correct 16 ms 1452 KB Output is correct
13 Correct 14 ms 1460 KB Output is correct
14 Correct 14 ms 1456 KB Output is correct
15 Incorrect 38 ms 3444 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 5 ms 636 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 17 ms 1452 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 1152 KB Output is correct
12 Correct 16 ms 1452 KB Output is correct
13 Correct 14 ms 1460 KB Output is correct
14 Correct 14 ms 1456 KB Output is correct
15 Incorrect 38 ms 3444 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 5 ms 636 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 17 ms 1452 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 1152 KB Output is correct
12 Correct 16 ms 1452 KB Output is correct
13 Correct 14 ms 1460 KB Output is correct
14 Correct 14 ms 1456 KB Output is correct
15 Incorrect 38 ms 3444 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -