제출 #554620

#제출 시각아이디문제언어결과실행 시간메모리
554620ArvinSuper Dango Maker (JOI22_dango3)C++17
22 / 100
893 ms274184 KiB
#include "dango3.h"
#include <bits/stdc++.h>

using namespace std;

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

map<vector<int>, int> mp;

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);
	}
	
	auto ask = [&](vector<int> &v) -> int {
		if(mp.count(v)) return mp[v];
		return mp[v] = Query(v);
	};
	
	int cnt = m;
	while(cnt > 0){
		vector<int> w = v;
		int lst = 0;
		int left = 0, right = w.size()-1;
		while(left <= right){
			int mid = (left+right) >> 1;
			
			vector<int> z;
			for(int x=0;x<=mid;x++){
				z.push_back(w[x]);
			}
			
			if(ask(z) > 0){
				lst = mid;
				right = mid-1;
			} else {
				left = mid+1;
			}
		}
		
		vector<int> ans;
		int pos = 0;
		while(pos < lst){
			int bound = 0;
			int left = pos, right = lst;
			while(left <= right){
				int mid = (left+right) >> 1;
				
				vector<int> z = ans;
				for(int x=mid;x<=lst;x++){
					z.push_back(w[x]);
				}
				
				if(ask(z) > 0){
					bound = mid;
					left = mid+1;
				} else {
					right = mid-1;
				}
			}
			
			ans.push_back(w[bound]);
			pos = bound+1;
		}
		ans.push_back(w[lst]);
		
		v.clear();
		pos = 0;
		for(int x=0;x<w.size();x++){
			while(pos < ans.size() && ans[pos] < w[x]){
				pos++;
			}
			if(pos < ans.size() && ans[pos] == w[x]) continue;
			
			v.push_back(w[x]);
		}
		
		Answer(ans);
		cnt--;
	}
//	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);
//	}
}

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

dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:74:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |   for(int x=0;x<w.size();x++){
      |               ~^~~~~~~~~
dango3.cpp:75:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |    while(pos < ans.size() && ans[pos] < w[x]){
      |          ~~~~^~~~~~~~~~~~
dango3.cpp:78:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |    if(pos < ans.size() && ans[pos] == w[x]) continue;
      |       ~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...