답안 #952060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
952060 2024-03-23T04:53:32 Z goodspeed0208 Super Dango Maker (JOI22_dango3) C++17
100 / 100
919 ms 732 KB
#include "dango3.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;

namespace {

int variable_example = 1;

}  // namespace

void Solve(int n, int m) {
	srand(time(NULL));
	vector<int>used(n*m+1, 0);
	for (int k = 1 ; k <= m ; k++) {
		vector<int>rd(n*m+1);
		for (int i = 0 ; i <= n*m ; i++) rd[i] = i;
		random_shuffle(rd.begin()+1, rd.end());
		vector<int>v;
		vector<int>ans;
		for (int i = 1 ; i <= n*m ; i++) if (!used[rd[i]]) v.push_back(rd[i]);
		int num = 0;
		for (int i = 1 ; i <= n*m ; i++) {
			if (used[rd[i]]) continue;
			v.erase(find(v.begin(), v.end(), rd[i]));
		//	cout << rd[i] <<"\n";
			int q = Query(v);
			num++;
			if (q == m-k) {
				ans.push_back(rd[i]);
				used[rd[i]] = 1;
			} else {
				v.push_back(rd[i]);
			}
			if (ans.size() == n) break;
		}
		assert(num <= n*10);
		Answer(ans);
	}
}
//g++ -std=gnu++14 -O2 -o grader grader.cpp dango3.cpp

Compilation message

dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:35:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |    if (ans.size() == n) break;
      |        ~~~~~~~~~~~^~~~
dango3.cpp: At global scope:
dango3.cpp:8:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    8 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 348 KB Output is correct
2 Correct 83 ms 604 KB Output is correct
3 Correct 75 ms 600 KB Output is correct
4 Correct 77 ms 604 KB Output is correct
5 Correct 80 ms 580 KB Output is correct
6 Correct 77 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 366 ms 692 KB Output is correct
2 Correct 455 ms 600 KB Output is correct
3 Correct 361 ms 600 KB Output is correct
4 Correct 386 ms 728 KB Output is correct
5 Correct 919 ms 604 KB Output is correct
6 Correct 364 ms 732 KB Output is correct