QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#556137 | #3955. Archipelago | LaVuna47# | AC ✓ | 12ms | 19800kb | C++17 | 2.5kb | 2024-09-10 15:19:17 | 2024-09-10 15:19:18 |
Judging History
answer
/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define RFOR(i, n) for(int i = n-1; i >= 0; --i)
#define output_vec(vec) { FOR(i_, sz(vec)) cout << vec[i_] << ' '; cout << '\n'; }
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<bool> vb;
typedef short si;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
#define MAX_N 2020
vector<pll> p;
int n;
double d;
vector<int> G[MAX_N];
double dist(const pll& e1, const pll& e2)
{
return sqrt(pow(e1.x-e2.x, 2) + pow(e1.y - e2.y, 2));
}
void dfs(int v, vector<int>& vis, int marker)
{
vis[v] = marker;
for(auto to: G[v])
{
if(vis[to] == 0)
{
dfs(to, vis, marker);
}
}
}
int solve()
{
if(!(cin >> n >> d))
return 1;
p = vector<pll>(n);
FOR(i, n) cin >> p[i].x >> p[i].y;
FOR(i, n)
{
FOR(j, i)
{
if(dist(p[i], p[j]) <= d)
{
G[i].pb(j);
G[j].pb(i);
}
}
}
vector<int> vis(n, 0);
int marker = 1;
FOR(i, n)
{
if(vis[i] == 0)
{
dfs(i, vis, marker);
++marker;
}
}
vector<int> S(n+4, 0);
FOR(i, n)
{
S[vis[i]] += 1;
}
vector<int> res(n);
iota(all(res), 0);
sort(all(res), [&](int e1, int e2) -> bool {
return S[vis[e1]] > S[vis[e2]];
});
FOR(i, n)
cout << res[i]+1 << ' ';
cout << '\n';
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3800kb
input:
7 3 1 1 3 2 2 3 4 2 12 5 13 7 11 6
output:
1 2 3 4 5 6 7
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
3 4 2 5 5 0 4 4
output:
1 3 2
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
25 3 111 88 4 18 313 211 210 134 247 161 210 149 357 252 89 87 266 171 232 158 53 68 171 111 12 41 336 222 75 73 29 56 59 72 353 235 152 106 129 97 7 26 183 113 284 189 301 200 186 115
output:
13 25 24 23 22 21 20 19 18 17 16 15 14 1 12 11 10 9 8 7 6 5 4 3 2
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
25 3 6 9 6 6 3 0 12 12 0 3 12 9 9 0 3 3 12 6 6 3 3 6 12 3 0 0 9 3 6 0 0 12 3 9 6 12 9 6 3 12 12 0 9 9 0 6 0 9 9 12
output:
13 25 24 23 22 21 20 19 18 17 16 15 14 1 12 11 10 9 8 7 6 5 4 3 2
result:
ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 3904kb
input:
25 5 0 102 0 144 0 138 0 36 0 72 0 54 0 90 0 24 0 132 0 66 0 0 0 84 0 78 0 120 0 18 0 12 0 30 0 96 0 114 0 108 0 6 0 48 0 42 0 126 0 60
output:
13 25 24 23 22 21 20 19 18 17 16 15 14 1 12 11 10 9 8 7 6 5 4 3 2
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3984kb
input:
25 3 0 27 0 69 0 36 0 3 0 72 0 54 0 21 0 15 0 57 0 24 0 66 0 33 0 0 0 51 0 45 0 18 0 12 0 63 0 30 0 39 0 6 0 48 0 42 0 9 0 60
output:
13 25 24 23 22 21 20 19 18 17 16 15 14 1 12 11 10 9 8 7 6 5 4 3 2
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
25 3 0 64 0 20 0 56 0 76 0 16 0 36 0 72 0 28 0 32 0 24 0 44 0 4 0 40 0 0 0 84 0 12 0 80 0 8 0 92 0 96 0 52 0 88 0 48 0 68 0 60
output:
13 25 24 23 22 21 20 19 18 17 16 15 14 1 12 11 10 9 8 7 6 5 4 3 2
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3972kb
input:
25 12 194 188 293 305 254 265 69 46 283 298 163 146 230 232 44 27 217 211 261 274 320 370 47 31 305 351 125 97 296 327 34 26 18 2 243 248 105 81 219 227 159 138 93 70 183 165 142 115 107 90
output:
8 12 16 25 3 6 21 10 19 13 24 23 22 20 18 17 15 14 1 11 9 7 5 4 2
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
20 10 0 0 10 30 30 0 47 55 10 10 0 20 30 20 20 20 20 30 20 0 0 30 20 10 31 35 30 10 44 37 0 10 10 20 51 67 10 0 70 69
output:
2 19 17 16 14 12 11 10 9 8 7 6 5 3 1 13 15 4 18 20
result:
ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
25 7 1 3 3 0 0 2 2 1 0 3 4 0 1 2 3 3 4 4 2 2 0 4 4 1 1 1 3 2 0 0 1 4 2 3 4 2 1 0 0 1 3 1 2 0 4 3 3 4 2 4
output:
13 25 24 23 22 21 20 19 18 17 16 15 14 1 12 11 10 9 8 7 6 5 4 3 2
result:
ok
Test #11:
score: 0
Accepted
time: 4ms
memory: 3864kb
input:
1937 3 450874 463736 425600 437931 1076434 1115420 1831853 1924061 1082975 1124089 1516736 1582110 774378 800971 1079369 1118978 990985 1026102 1540547 1614631 332841 345307 760457 788322 342324 360308 1130132 1165908 1561518 1636935 850008 877177 1347029 1396095 863812 891225 1707092 1781490 609525...
output:
1287 1302 1301 1300 1299 1298 1297 1296 1295 1294 1293 1292 1291 1290 1289 1288 1303 1286 1285 1284 1283 1282 1281 1280 1279 1278 1277 1276 1275 1274 1273 1318 1332 1331 1330 1329 1328 1327 1326 1325 1324 1323 1322 1321 1320 1319 1272 1317 1316 1315 1314 1313 1312 1311 1310 1309 1308 1307 1306 1305 ...
result:
ok
Test #12:
score: 0
Accepted
time: 2ms
memory: 4012kb
input:
1936 3 78 39 99 126 90 42 93 15 9 0 15 30 66 66 111 123 96 123 60 81 117 96 45 78 114 60 63 117 54 87 9 9 66 42 108 126 24 21 81 36 120 9 45 54 66 93 30 111 12 129 96 114 117 105 120 120 84 102 57 60 75 102 99 108 63 114 12 90 105 117 90 60 27 72 105 6 51 126 15 108 108 117 111 24 66 84 123 45 87 3 ...
output:
1286 1301 1300 1299 1298 1297 1296 1295 1294 1293 1292 1291 1290 1289 1288 1287 1302 1285 1284 1283 1282 1281 1280 1279 1278 1277 1276 1275 1274 1273 1272 1317 1331 1330 1329 1328 1327 1326 1325 1324 1323 1322 1321 1320 1319 1318 1271 1316 1315 1314 1313 1312 1311 1310 1309 1308 1307 1306 1305 1304 ...
result:
ok
Test #13:
score: 0
Accepted
time: 4ms
memory: 3796kb
input:
2000 5 0 378 0 8724 0 11064 0 3282 0 6666 0 8100 0 9054 0 1224 0 10338 0 11958 0 408 0 9522 0 9900 0 4080 0 5124 0 7464 0 636 0 10368 0 11322 0 5454 0 5880 0 8358 0 1104 0 10698 0 5922 0 480 0 666 0 9780 0 4338 0 7722 0 9156 0 10110 0 2280 0 1464 0 10578 0 10956 0 6180 0 8520 0 738 0 10140 0 11424 0...
output:
1329 1344 1343 1342 1341 1340 1339 1338 1337 1336 1335 1334 1333 1332 1331 1330 1345 1328 1327 1326 1325 1324 1323 1322 1321 1320 1319 1318 1317 1316 1315 1314 1360 1375 1374 1373 1372 1371 1370 1369 1368 1367 1366 1365 1364 1363 1362 1361 1313 1359 1358 1357 1356 1355 1354 1353 1352 1351 1350 1349 ...
result:
ok
Test #14:
score: 0
Accepted
time: 5ms
memory: 4008kb
input:
2000 3 0 378 0 1113 0 2547 0 3282 0 3591 0 5931 0 489 0 1224 0 4347 0 408 0 4080 0 4389 0 5124 0 636 0 2805 0 5454 0 5880 0 369 0 747 0 1104 0 5922 0 480 0 666 0 2169 0 4338 0 4647 0 2280 0 627 0 1464 0 5445 0 189 0 738 0 5007 0 657 0 2160 0 987 0 1722 0 5703 0 4887 0 180 0 2520 0 2829 0 4998 0 510 ...
output:
1329 1344 1343 1342 1341 1340 1339 1338 1337 1336 1335 1334 1333 1332 1331 1330 1345 1328 1327 1326 1325 1324 1323 1322 1321 1320 1319 1318 1317 1316 1315 1314 1360 1375 1374 1373 1372 1371 1370 1369 1368 1367 1366 1365 1364 1363 1362 1361 1313 1359 1358 1357 1356 1355 1354 1353 1352 1351 1350 1349 ...
result:
ok
Test #15:
score: 0
Accepted
time: 4ms
memory: 3832kb
input:
2000 3 0 7616 0 532 0 2872 0 4172 0 5776 0 1224 0 3356 0 4640 0 7028 0 408 0 1708 0 4080 0 5124 0 7464 0 636 0 2176 0 4564 0 5880 0 7948 0 1104 0 3428 0 5000 0 6364 0 480 0 1588 0 3928 0 5228 0 6832 0 964 0 2280 0 4412 0 5696 0 7316 0 1464 0 2764 0 4880 0 6180 0 328 0 1948 0 3232 0 5620 0 6680 0 812...
output:
1329 1344 1343 1342 1341 1340 1339 1338 1337 1336 1335 1334 1333 1332 1331 1330 1345 1328 1327 1326 1325 1324 1323 1322 1321 1320 1319 1318 1317 1316 1315 1314 1360 1375 1374 1373 1372 1371 1370 1369 1368 1367 1366 1365 1364 1363 1362 1361 1313 1359 1358 1357 1356 1355 1354 1353 1352 1351 1350 1349 ...
result:
ok
Test #16:
score: 0
Accepted
time: 4ms
memory: 3828kb
input:
1937 12 377135 395489 1687262 1689905 812152 843106 226215 248895 1564031 1565502 884767 917333 1392483 1417902 1051139 1086488 37362 41112 1327427 1358465 2994 3886 1366751 1395642 1504965 1511950 395136 418725 1806677 1806412 1461930 1477980 1073754 1112505 347792 359186 730665 755599 875004 90674...
output:
1287 1302 1301 1300 1299 1298 1297 1296 1295 1294 1293 1292 1291 1290 1289 1288 1303 1286 1285 1284 1283 1282 1281 1280 1279 1278 1277 1276 1275 1274 1273 1318 1332 1331 1330 1329 1328 1327 1326 1325 1324 1323 1322 1321 1320 1319 1272 1317 1316 1315 1314 1313 1312 1311 1310 1309 1308 1307 1306 1305 ...
result:
ok
Test #17:
score: 0
Accepted
time: 4ms
memory: 4076kb
input:
1941 10 430 60 110 190 330 240 170 130 390 50 210 310 3833 3441 130 170 410 330 30 100 70 400 150 280 170 420 410 0 90 130 270 390 290 320 240 160 150 70 170 250 10 310 390 410 130 50 20 280 330 330 410 290 30 220 360 350 270 160 90 420 330 0 420 130 40 230 150 160 190 390 220 60 120 120 10 430 250 ...
output:
1288 1303 1302 1301 1300 1299 1298 1297 1296 1295 1294 1293 1292 1291 1290 1289 1304 1287 1286 1285 1284 1283 1282 1281 1280 1279 1278 1277 1276 1275 1274 1319 1333 1332 1331 1330 1329 1328 1327 1326 1325 1324 1323 1322 1321 1320 1273 1318 1317 1316 1315 1314 1313 1312 1311 1310 1309 1308 1307 1306 ...
result:
ok
Test #18:
score: 0
Accepted
time: 12ms
memory: 19800kb
input:
2000 66 31 6 40 22 21 28 4 36 43 3 7 25 29 44 33 41 36 34 9 0 34 8 15 30 37 13 24 14 13 20 3 2 28 10 31 15 1 40 40 29 21 37 4 35 8 38 7 22 29 37 33 34 16 38 36 41 41 34 22 12 9 9 34 3 24 21 13 13 0 14 38 31 3 11 28 1 1 33 40 4 4 42 7 15 16 29 41 43 22 7 44 16 12 41 34 26 24 28 10 19 13 6 0 5 38 22 2...
output:
1329 1344 1343 1342 1341 1340 1339 1338 1337 1336 1335 1334 1333 1332 1331 1330 1345 1328 1327 1326 1325 1324 1323 1322 1321 1320 1319 1318 1317 1316 1315 1314 1360 1375 1374 1373 1372 1371 1370 1369 1368 1367 1366 1365 1364 1363 1362 1361 1313 1359 1358 1357 1356 1355 1354 1353 1352 1351 1350 1349 ...
result:
ok
Test #19:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
10 1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
output:
1 2 3 4 5 6 7 8 9 10
result:
ok
Test #20:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
1 1 1 1
output:
1
result:
ok
Test #21:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
6 3 1 1 4 4 5 5 8 8 9 9 10 10
output:
4 5 6 2 3 1
result:
ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
4 2 1 1 2 2 8 8 9 9
output:
1 2 3 4
result:
ok