//tl shit problem ^^
#include <bits/stdc++.h>
#pragma GCC optimize("O0")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
#define MAX 301010
#define MAXS 20
#define INF 1000000010
#define bb ' '
#define ln '\n'
#define Ln '\n'
pair<pi, pi> in[MAX];
int X[MAX];
int Y[MAX];
int R[MAX];
int ind[MAX];
int ri[MAX];
int ans[MAX];
inline ll sq(ll x) {
return x * x;
}
inline bool chk(int i, int j) {
return sq(X[i] - X[j]) + sq(Y[i] - Y[j]) <= sq(R[i] + R[j]);
}
bool isrange(int x, int y) {
if (x < 0 || y < 0) return false;
return true;
}
inline ll trans(int x, int y) {
return ((ll)x * (ll)INF) + y;
}
bool cmp(pair<pi, pi>& p1, pair<pi, pi>& p2) {
if (p1.first.first == p2.first.first) return p1.first.second < p2.first.second;
else return p1.first.first > p2.first.first;
}
unordered_map<ll, vector<int>> mp;
//구현 2. mmap/write 이용
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
using namespace std;
/////////////////////////////////////////////////////////////////////////////////////////////
/*
* Author : jinhan814
* Date : 2021-05-06
* Source : https://blog.naver.com/jinhan814/222266396476
* Description : FastIO implementation for cin, cout. (mmap ver.)
*/
constexpr int SZ = 1 << 20;
class INPUT {
private:
char* p;
bool __END_FLAG__, __GETLINE_FLAG__;
public:
explicit operator bool() { return !__END_FLAG__; }
INPUT() {
struct stat st; fstat(0, &st);
p = (char*)mmap(0, st.st_size, PROT_READ, MAP_SHARED, 0, 0);
}
bool IsBlank(char c) { return c == ' ' || c == '\n'; }
bool IsEnd(char c) { return c == '\0'; }
char _ReadChar() { return *p++; }
char ReadChar() {
char ret = _ReadChar();
for (; IsBlank(ret); ret = _ReadChar());
return ret;
}
template<typename T> T ReadInt() {
T ret = 0; char cur = _ReadChar(); bool flag = 0;
for (; IsBlank(cur); cur = _ReadChar());
if (cur == '-') flag = 1, cur = _ReadChar();
for (; !IsBlank(cur) && !IsEnd(cur); cur = _ReadChar()) ret = 10 * ret + (cur & 15);
if (IsEnd(cur)) __END_FLAG__ = 1;
return flag ? -ret : ret;
}
string ReadString() {
string ret; char cur = _ReadChar();
for (; IsBlank(cur); cur = _ReadChar());
for (; !IsBlank(cur) && !IsEnd(cur); cur = _ReadChar()) ret.push_back(cur);
if (IsEnd(cur)) __END_FLAG__ = 1;
return ret;
}
double ReadDouble() {
string ret = ReadString();
return stod(ret);
}
string getline() {
string ret; char cur = _ReadChar();
for (; cur != '\n' && !IsEnd(cur); cur = _ReadChar()) ret.push_back(cur);
if (__GETLINE_FLAG__) __END_FLAG__ = 1;
if (IsEnd(cur)) __GETLINE_FLAG__ = 1;
return ret;
}
friend INPUT& getline(INPUT& in, string& s) { s = in.getline(); return in; }
} _in;
class OUTPUT {
private:
char write_buf[SZ];
int write_idx;
public:
~OUTPUT() { Flush(); }
explicit operator bool() { return 1; }
void Flush() {
write(1, write_buf, write_idx);
write_idx = 0;
}
void WriteChar(char c) {
if (write_idx == SZ) Flush();
write_buf[write_idx++] = c;
}
template<typename T> int GetSize(T n) {
int ret = 1;
for (n = n >= 0 ? n : -n; n >= 10; n /= 10) ret++;
return ret;
}
template<typename T> void WriteInt(T n) {
int sz = GetSize(n);
if (write_idx + sz >= SZ) Flush();
if (n < 0) write_buf[write_idx++] = '-', n = -n;
for (int i = sz; i-- > 0; n /= 10) write_buf[write_idx + i] = n % 10 | 48;
write_idx += sz;
}
void WriteString(string s) { for (auto& c : s) WriteChar(c); }
void WriteDouble(double d) { WriteString(to_string(d)); }
} _out;
/* operators */
INPUT& operator>> (INPUT& in, char& i) { i = in.ReadChar(); return in; }
INPUT& operator>> (INPUT& in, string& i) { i = in.ReadString(); return in; }
template<typename T, typename std::enable_if_t<is_arithmetic_v<T>>* = nullptr>
INPUT& operator>> (INPUT& in, T& i) {
if constexpr (is_floating_point_v<T>) i = in.ReadDouble();
else if constexpr (is_integral_v<T>) i = in.ReadInt<T>(); return in;
}
OUTPUT& operator<< (OUTPUT& out, char i) { out.WriteChar(i); return out; }
OUTPUT& operator<< (OUTPUT& out, string i) { out.WriteString(i); return out; }
template<typename T, typename std::enable_if_t<is_arithmetic_v<T>>* = nullptr>
OUTPUT& operator<< (OUTPUT& out, T i) {
if constexpr (is_floating_point_v<T>) out.WriteDouble(i);
else if constexpr (is_integral_v<T>) out.WriteInt<T>(i); return out;
}
/* macros */
#define fastio 1
#define cin _in
#define cout _out
#define istream INPUT
#define ostream OUTPUT
/////////////////////////////////////////////////////////////////////////////////////////////
signed main() {
int N;
cin >> N;
int i;
for (i = 1; i <= N; i++) cin >> in[i].second.first >> in[i].second.second >> in[i].first.first, in[i].first.second = i;
sort(in + 1, in + N + 1, cmp);
for (i = 1; i <= N; i++) tie(X[i], Y[i], R[i], ind[i]) = make_tuple(in[i].second.first + INF, in[i].second.second + INF, in[i].first.first, in[i].first.second);
int k;
int s, e;
e = 0;
for (k = 30; k >= 0; k--) {
int r = 1 << k;
s = e + 1;
if (R[s] < r / 2) continue;
mp.clear();
e = 0;
for (i = s; i <= N; i++) {
if (ans[i]) continue;
int x, y;
x = X[i] >> k;
y = Y[i] >> k;
if (R[i] < r / 2 && !e) e = i - 1;
mp[((ll)x << 31LL) + y].push_back(i);
}
if (e == 0) e = N;
for (i = s; i <= e; i++) {
if (ans[i]) continue;
ans[i] = i;
int x, y;
x = X[i] / r;
y = Y[i] / r;
int xx, yy;
for (xx = x - 2; xx <= x + 2; xx++) for (yy = y - 2; yy <= y + 2; yy++) {
ll t = ((ll)xx << 31LL) + yy;
for (auto c : mp[t]) if (!ans[c] && chk(c, i)) ans[c] = i;
/*
for (auto c : mp[t]) {
if (!ans[c] && chk(c, i)) ans[c] = i;
else if (!ans[c]) v.push_back(c);
}
mp[t] = v;
*/
}
}
}
for (i = 1; i <= N; i++) ri[ind[i]] = i;
for (i = 1; i <= N; i++) cout << ind[ans[ri[i]]] << bb;
}
Compilation message
circle_selection.cpp: In function 'INPUT& operator>>(INPUT&, T&)':
circle_selection.cpp:144:2: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
144 | else if constexpr (is_integral_v<T>) i = in.ReadInt<T>(); return in;
| ^~~~
circle_selection.cpp:144:60: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
144 | else if constexpr (is_integral_v<T>) i = in.ReadInt<T>(); return in;
| ^~~~~~
circle_selection.cpp: In function 'OUTPUT& operator<<(OUTPUT&, T)':
circle_selection.cpp:152:2: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
152 | else if constexpr (is_integral_v<T>) out.WriteInt<T>(i); return out;
| ^~~~
circle_selection.cpp:152:59: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
152 | else if constexpr (is_integral_v<T>) out.WriteInt<T>(i); return out;
| ^~~~~~
circle_selection.cpp: In member function 'void OUTPUT::Flush()':
circle_selection.cpp:115:8: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)' declared with attribute 'warn_unused_result' [-Wunused-result]
115 | write(1, write_buf, write_idx);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
20 ms |
9932 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
20 ms |
9924 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |