답안 #554612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
554612 2022-04-28T23:48:51 Z Arvin Super Dango Maker (JOI22_dango3) C++17
7 / 100
409 ms 604 KB
#include "dango3.h"
#include <bits/stdc++.h>

using namespace std;

//namespace {
//	int variable_example = 1;
//}  // namespace

void Solve(int n, int m) {
	int len = n*m;
	
	vector<int> v;
	for(int x=0;x<len;x++){
		v.push_back(x+1);
	}
	
	int lst = len-1;
	for(int x=len-1;x>=0;x--){
		int res = Query(v);
		
		if(res >= 1){
			lst = x;
		}
		
		v.pop_back();
	}
	
	bool valid[len];
	fill(valid, valid+len, false);
	for(int x=0;x<=lst;x++) valid[x] = true;
	
	for(int x=0;x<=lst;x++){
		valid[x] ^= 1;
		vector<int> w;
		for(int y=0;y<=lst;y++){
			if(valid[y]){
				w.push_back(y+1);
			}
		}
		
		int res = Query(w);
		
		if(res >= 1){
			continue;
		}
		
		valid[x] ^= 1;
	}
	
	int c[len];
	fill(c, c+len, -1);
	
	v.clear();
	for(int x=0;x<=lst;x++){
		if(valid[x]){
			v.push_back(x+1);
		}
	}
	for(int x=0;x<v.size();x++){
		c[v[x]-1] = x;
	}
	
	for(int x=0;x<v.size()-1;x++){
		vector<int> w;
		for(int y=0;y<x;y++){
			w.push_back(v[y]);
		}
		for(int y=x+1;y<v.size();y++){
			w.push_back(v[y]);
		}
		
		int cnt = 1;
		for(int y=0;y<len&&cnt<m;y++){
			if(c[y] == -1){
				w.push_back(y+1);
				
				if(Query(w) >= 1){
					cnt++;
					c[y] = c[v[x]-1];
				}
				
				w.pop_back();
			}
		}
	}
	for(int x=0;x<len;x++){
		if(c[x] == -1){
			c[x] = c[v.back()-1];
		}
	}
	
	vector<int> ans[n];
	for(int x=0;x<len;x++){
		ans[c[x]].push_back(x);
	}
	for(int x=0;x<m;x++){
		vector<int> w;
		for(int y=0;y<n;y++){
			w.push_back(ans[y][x]+1);
		}
		
		Answer(w);
	}
//	vector<int> x(3);
//	x[0] = 1;
//	x[1] = 2;
//	x[2] = 3;
//	variable_example = Query(x);
//	for (int i = 0; i < M; i++) {
//		std::vector<int> a(N);
//		for (int j = 0; j < N; j++) {
//		  a[j] = N * i + j + 1;
//		}
//		Answer(a);
//	}
}

Compilation message

dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:60:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |  for(int x=0;x<v.size();x++){
      |              ~^~~~~~~~~
dango3.cpp:64:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |  for(int x=0;x<v.size()-1;x++){
      |              ~^~~~~~~~~~~
dango3.cpp:69:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |   for(int y=x+1;y<v.size();y++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 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 34 ms 348 KB Output is correct
2 Correct 34 ms 360 KB Output is correct
3 Correct 10 ms 340 KB Output is correct
4 Correct 9 ms 340 KB Output is correct
5 Correct 34 ms 352 KB Output is correct
6 Correct 36 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 140 ms 436 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 409 ms 604 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -