제출 #376754

#제출 시각아이디문제언어결과실행 시간메모리
376754casperwangMinerals (JOI19_minerals)C++14
40 / 100
40 ms3364 KiB
#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);
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...