Submission #1213075

#TimeUsernameProblemLanguageResultExecution timeMemory
1213075emptypringlescan함박 스테이크 (JOI20_hamburg)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
int n,k;
int arr[200005][4];
vector<pair<int,int> > ans;
bool sc(int nk){
	if(nk==0){
		for(int i=0; i<n; i++) if(arr[i][0]!=-1) return false;
		return true;
	}
	int hm[5]={-1,-1,1e9,1e9,-1};
	for(int i=0; i<n; i++){
		if(arr[i][0]==-1) continue;
		for(int j=0; j<2; j++){
			hm[j]=max(hm[j],arr[i][j]);
		}
		for(int j=2; j<4; j++){
			hm[j]=min(hm[j],arr[i][j]);
		}
	}
	pair<int,int> pt;
	vector<pair<int,int> > undo;
	pt={hm[0],hm[1]};
	ans.push_back(pt);
	for(int i=0; i<n; i++){
		if(arr[i][0]==-1) continue;
		if(arr[i][0]<=pt.first&&pt.first<=arr[i][2]&&arr[i][1]<=pt.second&&pt.second<=arr[i][3]){
			undo.push_back({i,arr[i][0]});
			arr[i][0]=-1;
		}
	}
	if(sc(nk-1)) return true;
	ans.pop_back();
	for(auto i:undo) arr[i.first][0]=i.second;
	undo.clear();
	
	pt={hm[2],hm[1]};
	ans.push_back(pt);
	for(int i=0; i<n; i++){
		if(arr[i][0]==-1) continue;
		if(arr[i][0]<=pt.first&&pt.first<=arr[i][2]&&arr[i][1]<=pt.second&&pt.second<=arr[i][3]){
			undo.push_back({i,arr[i][0]});
			arr[i][0]=-1;
		}
	}
	if(sc(nk-1)) return true;
	ans.pop_back();
	for(auto i:undo) arr[i.first][0]=i.second;
	undo.clear();
	
	pt={hm[2],hm[3]};
	ans.push_back(pt);
	for(int i=0; i<n; i++){
		if(arr[i][0]==-1) continue;
		if(arr[i][0]<=pt.first&&pt.first<=arr[i][2]&&arr[i][1]<=pt.second&&pt.second<=arr[i][3]){
			undo.push_back({i,arr[i][0]});
			arr[i][0]=-1;
		}
	}
	if(sc(nk-1)) return true;
	ans.pop_back();
	for(auto i:undo) arr[i.first][0]=i.second;
	undo.clear();
	
	pt={hm[0],hm[3]};
	ans.push_back(pt);
	for(int i=0; i<n; i++){
		if(arr[i][0]==-1) continue;
		if(arr[i][0]<=pt.first&&pt.first<=arr[i][2]&&arr[i][1]<=pt.second&&pt.second<=arr[i][3]){
			undo.push_back({i,arr[i][0]});
			arr[i][0]=-1;
		}
	}
	if(sc(nk-1)) return true;
	ans.pop_back();
	for(auto i:undo) arr[i.first][0]=i.second;
	undo.clear();
	return false;
}
int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for(int i=0; i<n; i++) for(int j=0; j<4; j++) cin >> arr[i][j];
	if(k<4){
		assert(sc(k));
		for(auto i:ans) cout << i.first << ' ' << i.second << '\n';
	}
}

Compilation message (stderr)

hamburg.cpp: In function 'bool sc(int)':
hamburg.cpp:11:36: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
   11 |         int hm[5]={-1,-1,1e9,1e9,-1};
      |                                    ^
hamburg.cpp:11:36: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]