답안 #781120

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781120 2023-07-12T18:14:20 Z aZvezda Super Dango Maker (JOI22_dango3) C++17
100 / 100
746 ms 560 KB
#include "dango3.h"

#include <bits/stdc++.h>
using namespace std;

namespace {

int variable_example = 1;

}  // namespace


void Solve(int n, int m) {
	vector<int> lft = {};
	for(int i = 1; i <= n * m; i ++) { lft.push_back(i); }
	random_shuffle(lft.begin(), lft.end());
	int who = min(m, 5);
	for(int i = 0; i < m; i += who) {
		vector<int> now = {};
		for(int j = 0; j < lft.size(); j ++) now.push_back(lft[j]);
		const auto rem = [&](const auto x) {
			for(int j = 0; j < now.size(); j ++) {
				if(now[j] == x) {
					swap(now[j], now[now.size() - 1]);
					now.pop_back();
					return;
				}
			}
		};
		int now_cnt = min(who, m - i);
		int ptrbad = i * n;
		for(int j = i * n; ptrbad < (i + now_cnt) * n; j ++) {
			int old = lft[j];
			rem(old);
			int ans = Query(now);
			if(ans >= m - now_cnt) {
				swap(lft[j], lft[ptrbad]);
				ptrbad ++;
			} else {
				now.push_back(old);
			}
		}
	}
	for(int i = 0; i < m; i ++) {
		vector<int> now = {};
		for(int j = 0; j < lft.size(); j ++) now.push_back(lft[j]);
		const auto rem = [&](const auto x) {
			for(int j = 0; j < now.size(); j ++) {
				if(now[j] == x) {
					swap(now[j], now[now.size() - 1]);
					now.pop_back();
					return;
				}
			}
		};
		int ptrbad = i * n;
		for(int j = i * n; ptrbad < (i + 1) * n; j ++) {
			int old = lft[j];
			rem(old);
			int ans = Query(now);
			if(ans == m - 1) {
				swap(lft[j], lft[ptrbad]);
				ptrbad ++;
			} else {
				now.push_back(old);
			}
		}
	}
	for(int i = 0; i < m; i ++) {
		vector<int> group = {};
		for(int j = 0; j < n; j ++) {
			group.push_back(lft[i * n + j]);
		}
		Answer(group);
	}
}

Compilation message

dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int j = 0; j < lft.size(); j ++) now.push_back(lft[j]);
      |                  ~~^~~~~~~~~~~~
dango3.cpp: In instantiation of 'Solve(int, int)::<lambda(auto:23)> [with auto:23 = int]':
dango3.cpp:34:11:   required from here
dango3.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    for(int j = 0; j < now.size(); j ++) {
      |                   ~~^~~~~~~~~~~~
dango3.cpp:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for(int j = 0; j < lft.size(); j ++) now.push_back(lft[j]);
      |                  ~~^~~~~~~~~~~~
dango3.cpp: In instantiation of 'Solve(int, int)::<lambda(auto:24)> [with auto:24 = int]':
dango3.cpp:59:11:   required from here
dango3.cpp:48:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |    for(int j = 0; j < now.size(); j ++) {
      |                   ~~^~~~~~~~~~~~
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 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 340 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 5 ms 340 KB Output is correct
4 Correct 5 ms 340 KB Output is correct
5 Correct 5 ms 340 KB Output is correct
6 Correct 7 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 161 ms 436 KB Output is correct
2 Correct 146 ms 340 KB Output is correct
3 Correct 151 ms 432 KB Output is correct
4 Correct 149 ms 460 KB Output is correct
5 Correct 145 ms 432 KB Output is correct
6 Correct 145 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 661 ms 468 KB Output is correct
2 Correct 746 ms 560 KB Output is correct
3 Correct 654 ms 468 KB Output is correct
4 Correct 639 ms 560 KB Output is correct
5 Correct 632 ms 468 KB Output is correct
6 Correct 633 ms 560 KB Output is correct