답안 #781097

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781097 2023-07-12T17:42:59 Z aZvezda Super Dango Maker (JOI22_dango3) C++17
22 / 100
152 ms 528 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());
	cerr << "Starting ";
	for(int i = 0; i < n * m; i ++) { cerr << lft[i] << " "; } cerr << endl;
	for(int i = 0; i < m; i ++) {
		int l = i * n, r = lft.size();
		while(l < r - 1) {
			int m = (l + r) / 2ll;
			vector<int> now = {};
			for(int j = i * n; j < m; j ++) 
				now.push_back(lft[j]);
			if(Query(now) != 0)
				r = m;
			else
				l = m;
		}
		cerr << "Found out " << r << endl;
		vector<int> now = {};
		for(int j = i * n; j < r; j ++) 
			now.push_back(lft[j]);
			const auto rem = [&](const auto x) {
			for(int i = 0; i < now.size(); i ++) {
				if(now[i] == x) {
					swap(now[i], now[now.size() - 1]);
					now.pop_back();
					return;
				}
			}
		};
		int ptrbad = i * n;
		for(int j = i * n; j < r; j ++) {
			int old = lft[j];
			rem(old);
			int ans = Query(now);
			if(ans == 0) {
				swap(lft[j], lft[ptrbad]);
				ptrbad ++;
				now.push_back(old);
			}
		}
		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:33:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   33 |   for(int j = i * n; j < r; j ++)
      |   ^~~
dango3.cpp:35:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   35 |    const auto rem = [&](const auto x) {
      |    ^~~~~
dango3.cpp: In instantiation of 'Solve(int, int)::<lambda(auto:23)> [with auto:23 = int]':
dango3.cpp:47:11:   required from here
dango3.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    for(int i = 0; i < now.size(); i ++) {
      |                   ~~^~~~~~~~~~~~
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 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 4 ms 316 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
6 Correct 4 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 340 KB Output is correct
2 Correct 44 ms 340 KB Output is correct
3 Correct 43 ms 432 KB Output is correct
4 Correct 43 ms 340 KB Output is correct
5 Correct 46 ms 340 KB Output is correct
6 Correct 45 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 152 ms 528 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -