Submission #555816

# Submission time Handle Problem Language Result Execution time Memory
555816 2022-05-01T15:30:34 Z Arvin Super Dango Maker (JOI22_dango3) C++17
100 / 100
3517 ms 804 KB
#include "dango3.h"
#include <bits/stdc++.h>

using namespace std;

void Solve(int n, int m) {
	int len = n*m;
	
	vector<int> comp[m+1];
	int idx = 0;
	
	comp[idx].push_back(1);
	for(int x=2;x<=len;x++){
		int pos = idx+1;
		int left = 0, right = idx;
		while(left <= right){
			int mid = (left+right) >> 1;
			
			bool exist[len+1];
			fill(exist, exist+len+1, true);
			
			exist[x] = false;
			for(int y=0;y<=mid;y++){
				for(auto idx : comp[y]){
					exist[idx] = false;
				}
			}
			
			vector<int> w;
			for(int y=1;y<=len;y++){
				if(exist[y]) w.push_back(y);
			}
			
//			cout << x << " " << idx << " -> " << " " << mid << " " << ask(w) << "\n";
			if(Query(w) == m-(mid+1)){
				pos = mid;
				right = mid-1;
			} else {
				left = mid+1;
			}
		}
		
//		cout << x << " = " << pos << "\n";
		comp[pos].push_back(x);
		idx = max(idx, pos);
	}
	
	for(int x=0;x<m;x++){
		vector<int> w;
		for(int y=0;y<n;y++){
			w.push_back(comp[x][y]);
		}
		
		Answer(w);
	}
}
# Verdict Execution time Memory 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 0 ms 340 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 368 KB Output is correct
2 Correct 23 ms 372 KB Output is correct
3 Correct 28 ms 340 KB Output is correct
4 Correct 30 ms 304 KB Output is correct
5 Correct 21 ms 368 KB Output is correct
6 Correct 21 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 747 ms 452 KB Output is correct
2 Correct 731 ms 568 KB Output is correct
3 Correct 894 ms 576 KB Output is correct
4 Correct 904 ms 560 KB Output is correct
5 Correct 608 ms 460 KB Output is correct
6 Correct 615 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2902 ms 796 KB Output is correct
2 Correct 2844 ms 804 KB Output is correct
3 Correct 3517 ms 724 KB Output is correct
4 Correct 3472 ms 664 KB Output is correct
5 Correct 2383 ms 648 KB Output is correct
6 Correct 2455 ms 552 KB Output is correct