///huynhocute123///
#include<bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define pii pair<int,int>
#define piii pair<int,pair<int,int>>
#define pb push_back
#define pi M_PI
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, a, b) for(int i = b; i >= a; --i)
#define ALL(v) v.begin(),v.end()
#define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
#define out(name) if(fopen(name, "w")) freopen(name, "w", stdout);
//random_device rd;
//mt19937 rng(rd());
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("popcnt")
#define int long long
const int maxN = 1e6+ 9 ;
const int modd = 1e9 + 7;
const int base = 2309;
const int MAX = 1e9+9;
void minimize(int &u, int v){
if(v < u) u = v;
}
void maximize(int &u, int v){
if(v > u) u = v;
}
int n, k, t, m, res, ans[maxN];
int l, r;
bool vis[maxN];
int dx[] ={-1 , 0 , 1, -1, 0 , 1, -1, 0 ,-1 };
int dy[] ={-1, -1, -1, 0, 0 ,0 ,1, 1, 1 };
vector<int> e[maxN];
pii a[maxN],Na[maxN];
int R;
map<pii, set<int>>f;
bool cut(pii a ,pii b){
int d1 = a.F - b.F;
int d2 = a.S - b.S;
if(d1* d1 + d2 * d2 > 4 * R * R)return 0;
return 1;
}
long long tran(long long a ,long long b){
if(a >= 0)return a/b;
if( a < 0) return -( (b - a -1)/b);
}
void solve(){
cin >> n ;
FOR(i, 1, n){
int tmp;
cin >> a[i].F >> a[i].S >> tmp;
if(i > 2 && tmp != R)return;
R = tmp;
// cout << a[i].F << " ";
Na[i]= { tran(a[i].F, R* 2) , tran(a[i].S, R * 2) };
// cout << Na[i].F << " " <<Na[i].S << '\n';
f[Na[i]].insert(i);
}
FOR(i, 1, n){
if(ans[i])continue;
int X = Na[i].F , Y = Na[i].S;
FOR(ix, 0 , 8 ){
int Nx = X + dx[ix];
int Ny= Y + dy[ix];
// vector<int> era;
for(auto x : f[{Nx, Ny}] ){
if(ans[x] || !cut(a[i], a[x] ))continue;
ans[x] =i;
// era.pb(x);
}
// for(auto x : era)f[{Nx ,Ny}].erase(x);
// era.clear();
}
}
for(int i =1; i <= n ;i++)cout << ans[i] << " ";
}
signed main(){
// freopen("name.inp","r",stdin);
// freopen("name.out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
inp("task.inp");
t = 1;
// cin >> t;
while( t-- )solve();
}
Compilation message
circle_selection.cpp: In function 'long long int tran(long long int, long long int)':
circle_selection.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
50 | }
| ^
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:13:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~
circle_selection.cpp:89:5: note: in expansion of macro 'inp'
89 | inp("task.inp");
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
23896 KB |
Output is correct |
2 |
Correct |
10 ms |
23772 KB |
Output is correct |
3 |
Incorrect |
10 ms |
23960 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
23900 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
23900 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1509 ms |
322524 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
23896 KB |
Output is correct |
2 |
Correct |
10 ms |
23772 KB |
Output is correct |
3 |
Incorrect |
10 ms |
23960 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
23896 KB |
Output is correct |
2 |
Correct |
10 ms |
23772 KB |
Output is correct |
3 |
Incorrect |
10 ms |
23960 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |