Submission #376739

# Submission time Handle Problem Language Result Execution time Memory
376739 2021-03-12T02:56:39 Z casperwang Minerals (JOI19_minerals) C++14
0 / 100
1 ms 364 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]; }

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));

	deque <int> dq;
	vector <int> tmp;
	int now, prev=0;
	for (int i = 0; i < 2*N; i++) {
		int id = num[i];
		//debug(id);
		prev = now;
		now = Query(id);
		dq.push_back(id);
		if (now != prev+1) {
			while (true) {
				prev = now;
				now = Query(dq.front());
				if (now == prev-1) {
					tmp.pb(dq.front());
					dq.pop_front();
				} else {
					//debug(id, dq.front());
					Answer(id, dq.front());
					dq.pop_front();
					break;
				}
			}
		}
		for (int i : tmp) {
			dq.push_front(i);
			//debug(i);
			now = Query(i);
		}
		tmp.clear();
	}
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:27:18: warning: 'now' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |   if (now != prev+1) {
      |              ~~~~^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -