QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#405217 | #437. Fun Tour | Max_s_xaM | 47 | 46ms | 19500kb | C++20 | 1.6kb | 2024-05-05 13:58:12 | 2024-05-05 13:58:13 |
Judging History
answer
#include "fun.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
typedef double lf;
using namespace std;
const int MAXN = 1e5 + 10;
int n, q;
vector <int> res;
map <pair <int, int>, int> dist, tsz;
inline int GetDist(int u, int v)
{
if (dist[make_pair(u, v)]) return dist[make_pair(u, v)];
return dist[make_pair(u, v)] = dist[make_pair(v, u)] = hoursRequired(u - 1, v - 1);
}
inline int GetSize(int u, int v)
{
if (tsz[make_pair(u, v)]) return tsz[make_pair(u, v)];
return tsz[make_pair(u, v)] = attractionsBehind(u - 1, v - 1);
}
namespace Solution1
{
vector <int> tr[MAXN];
bool vis[MAXN];
int pt, mx;
void DFS(int u, int fa, int d)
{
if (mx < d) mx = d, pt = u;
for (auto v : tr[u])
if (v != fa && !vis[v]) DFS(v, u, d + 1);
}
int st[MAXN], top;
bool ban;
inline void Solve()
{
if (!ban)
{
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++)
if (GetDist(i, j) == 1) tr[i].push_back(j), tr[j].push_back(i);
}
mx = pt = 0, DFS(1, 0, 0);
st[top = 1] = pt, vis[st[top]] = 1;
while (top < n)
{
mx = pt = 0, DFS(st[top], 0, 0);
st[++top] = pt, vis[st[top]] = 1;
}
for (int i = 1; i <= top; i++) res.push_back(st[i] - 1);
}
}
vector <int> createFunTour(int N, int Q)
{
n = N, q = Q;
if (n * (n - 1) / 2 <= q) Solution1::Solve();
return res;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Accepted
Test #1:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
2 400000 1 0
output:
1 0
result:
ok correct
Subtask #2:
score: 0
Accepted
Test #3:
score: 0
Accepted
time: 1ms
memory: 4032kb
input:
4 400000 1 0 2 0 3 1
output:
3 2 1 0
result:
ok correct
Subtask #3:
score: 0
Accepted
Test #9:
score: 0
Accepted
time: 1ms
memory: 3792kb
input:
4 400000 1 0 2 1 3 2
output:
3 0 2 1
result:
ok correct
Subtask #4:
score: 0
Accepted
Test #13:
score: 0
Accepted
time: 1ms
memory: 4016kb
input:
4 400000 0 1 0 2 0 3
output:
1 2 3 0
result:
ok correct
Subtask #5:
score: 0
Accepted
Test #20:
score: 0
Accepted
time: 1ms
memory: 3980kb
input:
18 400000 1 0 2 0 3 1 4 1 5 2 6 2 7 3 8 3 9 4 10 4 11 5 12 5 13 6 14 6 15 7 16 7 17 8
output:
15 11 16 12 17 13 7 14 8 5 9 6 10 2 3 0 4 1
result:
ok correct
Subtask #6:
score: 0
Accepted
Test #27:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
18 400000 7 6 8 7 5 8 4 5 3 4 9 3 10 11 12 10 13 12 14 13 9 14 2 9 15 2 16 15 17 16 1 17 0 1
output:
6 0 7 1 11 17 8 10 16 5 12 15 4 13 2 3 14 9
result:
ok correct
Subtask #7:
score: 0
Accepted
Test #33:
score: 0
Accepted
time: 46ms
memory: 19468kb
input:
500 400000 33 414 398 33 254 398 400 254 376 400 302 376 466 302 362 466 301 362 267 301 417 267 413 417 14 413 305 14 353 305 83 353 227 83 57 227 446 57 406 446 154 406 336 154 195 336 405 195 264 405 76 264 203 76 459 203 178 459 72 178 296 72 488 296 404 488 60 404 156 60 393 156 108 393 216 108...
output:
414 212 33 88 398 124 254 399 400 190 376 10 302 366 466 234 362 432 301 28 267 188 417 237 413 64 14 268 305 39 353 349 83 345 227 125 57 70 446 276 406 420 154 369 336 48 195 211 405 482 264 8 76 22 203 487 459 9 178 230 72 339 296 95 488 340 404 50 60 102 156 174 393 47 108 461 216 424 106 181 31...
result:
ok correct
Subtask #8:
score: 0
Accepted
Test #41:
score: 0
Accepted
time: 46ms
memory: 19500kb
input:
501 400000 1 0 2 0 3 1 4 1 5 2 6 2 7 3 8 3 9 4 10 4 11 5 12 5 13 6 14 6 15 7 16 7 17 8 18 8 19 9 20 9 21 10 22 10 23 11 24 11 25 12 26 12 27 13 28 13 29 14 30 14 31 15 32 15 33 16 34 16 35 17 36 17 37 18 38 18 39 19 40 19 41 20 42 20 43 21 44 21 45 22 46 22 47 23 48 23 49 24 50 24 51 25 52 25 53 26 ...
output:
255 383 256 384 257 385 258 386 259 387 260 388 261 389 262 390 263 391 264 392 265 393 266 394 267 395 268 396 269 397 270 398 271 399 272 400 273 401 274 402 275 403 276 404 277 405 278 406 279 407 280 408 281 409 282 410 283 411 284 412 285 413 286 414 287 415 288 416 289 417 290 418 291 419 292 ...
result:
ok correct
Subtask #9:
score: 0
Wrong Answer
Test #51:
score: 0
Wrong Answer
time: 0ms
memory: 3892kb
input:
1000 400000 6 5 7 8 6 7 9 6 11 10 11 12 13 11 14 15 13 14 9 13 16 9 18 17 18 19 20 18 22 21 22 23 20 22 24 20 26 25 26 27 28 26 30 29 30 31 28 30 24 28 16 24 32 16 33 32 35 34 35 36 37 35 39 38 39 40 37 39 41 37 43 42 43 44 45 43 47 46 47 48 45 47 41 45 49 41 50 51 52 50 54 53 54 55 52 54 56 52 58 5...
output:
WA: Invalid size
result:
wrong output format Expected integer, but "WA:" found
Subtask #10:
score: 0
Wrong Answer
Test #59:
score: 0
Wrong Answer
time: 28ms
memory: 18260kb
input:
99999 400000 11681 58292 11681 63929 49752 11681 30596 74400 30596 39261 49752 30596 19390 49752 89694 31923 19390 89694 54297 19390 42389 12902 42389 60328 72803 42389 69881 43761 69881 95741 72803 69881 96271 72803 63872 20658 63872 93588 35833 63872 48418 44153 35833 48418 96271 35833 54297 96271...
output:
WA: Invalid size
result:
wrong output format Expected integer, but "WA:" found
Subtask #11:
score: 10
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Subtask #12:
score: 16
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #6:
100%
Accepted
Dependency #7:
100%
Accepted
Subtask #13:
score: 21
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #8:
100%
Accepted
Subtask #14:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #6:
100%
Accepted
Dependency #9:
0%
Subtask #15:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #6:
100%
Accepted
Dependency #7:
100%
Accepted
Dependency #8:
100%
Accepted
Dependency #9:
0%