Submission #376754

# Submission time Handle Problem Language Result Execution time Memory
376754 2021-03-12T03:21:37 Z casperwang Minerals (JOI19_minerals) C++14
40 / 100
40 ms 3364 KB
#include "minerals.h"
#include <bits/stdc++.h>
#define All(x) x.begin(), x.end()
#define pb emplace_back
using namespace std;
#define debug(args...) kout("[ " + string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }

int pre, now;

void check(vector <int> A, vector <int> B) {
	if (A.size() == 1) {
		Answer(A[0], B[0]);
		return;
	}
	int len = B.size() / 2;
	vector <int> LA, RA, LB, RB;
	for (int i = 0; i < len; i++) {
		pre = now;
		now = Query(B[i]);
		LB.pb(B[i]);
	}
	for (int i = 0; i < A.size(); i++) {
		pre = now;
		now = Query(A[i]);
		if (now != pre + 1) {
			LA.pb(A[i]);
		} else {
			RA.pb(A[i]);
		}
		pre = now;
		now = Query(A[i]);
	}
	for (int i = 0; i < len; i++) {
		pre = now;
		now = Query(B[i]);
	}
	for (int i = len; i < B.size(); i++) {
		RB.pb(B[i]);
	}
	check(LA, LB);
	check(RA, RB);
}

void Solve(int N) {
	srand(time(NULL));

	vector <int> num(2*N);
	for (int i = 0; i < 2*N; i++) num[i] = i+1;
	random_shuffle(All(num));

	vector <int> A, B;
	for (int id : num) {
		pre = now;
		now = Query(id);
		if (now != pre + 1) {
			B.pb(id);
		} else {
			A.pb(id);
		}
	}
	for (int id : num) {
		pre = now;
		now = Query(id);
	}
	check(A, B);
}

Compilation message

minerals.cpp: In function 'void check(std::vector<int>, std::vector<int>)':
minerals.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for (int i = 0; i < A.size(); i++) {
      |                  ~~^~~~~~~~~~
minerals.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  for (int i = len; i < B.size(); i++) {
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Correct 6 ms 620 KB Output is correct
4 Correct 12 ms 876 KB Output is correct
5 Correct 26 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 6 ms 620 KB Output is correct
8 Correct 12 ms 876 KB Output is correct
9 Correct 26 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 16 ms 1132 KB Output is correct
12 Correct 22 ms 1516 KB Output is correct
13 Correct 22 ms 1516 KB Output is correct
14 Correct 24 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 6 ms 620 KB Output is correct
8 Correct 12 ms 876 KB Output is correct
9 Correct 26 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 16 ms 1132 KB Output is correct
12 Correct 22 ms 1516 KB Output is correct
13 Correct 22 ms 1516 KB Output is correct
14 Correct 24 ms 1516 KB Output is correct
15 Incorrect 40 ms 3364 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 6 ms 620 KB Output is correct
8 Correct 12 ms 876 KB Output is correct
9 Correct 26 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 16 ms 1132 KB Output is correct
12 Correct 22 ms 1516 KB Output is correct
13 Correct 22 ms 1516 KB Output is correct
14 Correct 24 ms 1516 KB Output is correct
15 Incorrect 40 ms 3364 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 6 ms 620 KB Output is correct
8 Correct 12 ms 876 KB Output is correct
9 Correct 26 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 16 ms 1132 KB Output is correct
12 Correct 22 ms 1516 KB Output is correct
13 Correct 22 ms 1516 KB Output is correct
14 Correct 24 ms 1516 KB Output is correct
15 Incorrect 40 ms 3364 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 6 ms 620 KB Output is correct
8 Correct 12 ms 876 KB Output is correct
9 Correct 26 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 16 ms 1132 KB Output is correct
12 Correct 22 ms 1516 KB Output is correct
13 Correct 22 ms 1516 KB Output is correct
14 Correct 24 ms 1516 KB Output is correct
15 Incorrect 40 ms 3364 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 6 ms 620 KB Output is correct
8 Correct 12 ms 876 KB Output is correct
9 Correct 26 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 16 ms 1132 KB Output is correct
12 Correct 22 ms 1516 KB Output is correct
13 Correct 22 ms 1516 KB Output is correct
14 Correct 24 ms 1516 KB Output is correct
15 Incorrect 40 ms 3364 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 6 ms 620 KB Output is correct
8 Correct 12 ms 876 KB Output is correct
9 Correct 26 ms 1516 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 16 ms 1132 KB Output is correct
12 Correct 22 ms 1516 KB Output is correct
13 Correct 22 ms 1516 KB Output is correct
14 Correct 24 ms 1516 KB Output is correct
15 Incorrect 40 ms 3364 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -