답안 #732743

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
732743 2023-04-29T08:53:10 Z minhcool 원 고르기 (APIO18_circle_selection) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
 
//#define int long long
#define fi first
#define se second
#define pb push_back
//#define mp make_pair
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
 
const int N = 3e5 + 5;
 
const int oo = 1e18 + 7, mod = 1e9 + 7;
 
int n, x[N], y[N], r[N];
 
int ans[N];
 
bool out[N];
 
unordered_map<int, int> mp;
vector<ii> vc[N];
 
bool ck(int i, int j){
//	cout << i << " " << j << "\n";
	long long dist = ((1LL * (x[i] - x[j]) * (x[i] - x[j]) + 1LL * (y[i] - y[j]) * (y[i] - y[j]));
	long long rd = 1LL * (r[i] + r[j]) * (r[i] + r[j]);
	return (dist <= rd);
}
 
void process(){
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> r[i];
	set<ii> rem;
	for(int i = 1; i <= n; i++) rem.insert({-r[i], i});
	bool chk = 1;
	for(int i = 1; i <= n; i++) chk &= (r[i] == 1);
	if(chk){
		for(int i = 1; i <= n; i++) cout << i << " ";
		cout << "\n";
		exit(0);
	}
	for(int i = 30; i >= 0; i--){// executing with radius (1LL << (i - 1)) to (1LL << i)
		int rad = (1LL << i);
		mp.clear();
		for(int j = 1; j <= n; j++) vc[j].clear();
		vector<int> diff;
		for(int j = 1; j <= n; j++) if(!out[j]) diff.pb(x[j] / rad);
		sort(diff.begin(), diff.end());
		diff.resize(unique(diff.begin(), diff.end()) - diff.begin());
		for(int j = 0; j < diff.size(); j++) mp[diff[j]] = j + 1;
		for(int j = 1; j <= n; j++){
			if(!out[j]){
				//cout << "OK " << rad << " " << j << " " << x[j]/rad << " " << y[j] << "\n";
				vc[mp[x[j]/rad]].pb({y[j], j});
			}
		}
		for(int j = 1; j <= n; j++) sort(vc[j].begin(), vc[j].end());
		while(!rem.empty() && -((*rem.begin()).fi) >= (1LL << (i - 1))){
			int ind = (*rem.begin()).se;
		//	cout << rad << " " << ind << "\n";
			assert(!out[ind]);
			out[ind] = 1;
			ans[ind] = ind;
			rem.erase({-r[ind], ind});
			for(int i2 = x[ind]/rad - 5; i2 <= x[ind]/rad + 5; i2++){
				if(mp.find(i2) == mp.end()) continue;
				int temp = mp[i2];
				int le = (y[ind]/rad) - 5, ri = (y[ind] / rad) + 5;
			//	cout << 
				le *= rad, ri *= rad;
			//	cout << le << " " << ri << "\n";
				vector<ii>::iterator it = lower_bound(vc[temp].begin(), vc[temp].end(), make_pair(le, -oo));
				for(; it != vc[temp].end(); it++){
					if((*it).fi > ri) break;
					if(out[(*it).se]) continue;
					if(ck(ind, (*it).se)){
						//cout << ind << " " << (*it).se << "\n";
						ans[(*it).se] = ind;
						rem.erase({-r[(*it).se], (*it).se});
						out[(*it).se] = 1;
					}
				}
			}
		}
	}
	for(int i = 1; i <= n; i++) if(!ans[i]) ans[i] = i;
	for(int i = 1; i <= n; i++) cout << ans[i] << " ";
	cout << "\n";
}
 
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	

Compilation message

circle_selection.cpp:16:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   16 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
circle_selection.cpp: In function 'bool ck(int, int)':
circle_selection.cpp:29:95: error: expected ')' before ';' token
   29 |  long long dist = ((1LL * (x[i] - x[j]) * (x[i] - x[j]) + 1LL * (y[i] - y[j]) * (y[i] - y[j]));
      |                   ~                                                                           ^
      |                                                                                               )
circle_selection.cpp: In function 'void process()':
circle_selection.cpp:54:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   for(int j = 0; j < diff.size(); j++) mp[diff[j]] = j + 1;
      |                  ~~^~~~~~~~~~~~~
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:97:12: error: expected '}' at end of input
   97 |  cin.tie(0);
      |            ^
circle_selection.cpp:95:14: note: to match this '{'
   95 | signed main(){
      |              ^