# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1023826 |
2024-07-15T07:09:23 Z |
dozer |
Dreaming (IOI13_dreaming) |
C++14 |
|
1000 ms |
18588 KB |
#include <bits/stdc++.h>
using namespace std;
#include "dreaming.h"
#define sp " "
#define endl "\n"
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define mid (l + r) / 2
#define LL node * 2
#define RR node * 2 + 1
#define ll long long
#define MAXN 300005
const int modulo = 1e9 + 7;
const ll INF = 2e18 + 7;
#define fail(s, x...) do { \
fprintf(stderr, s "\n", ## x); \
exit(1); \
} while(0)
#define MAX_N 100000
int maks[MAXN], sub_maks[MAXN], maks3[MAXN], vis[MAXN];
vector<pii> adj[MAXN];
int MINI;
void dfs2(int node, int root){
int ans = 0;
for (auto i : adj[node]){
if (i.st == root) continue;
dfs2(i.st, node);
ans = max(ans, sub_maks[i.st] + i.nd);
}
sub_maks[node] = ans;
}
void dfs3(int node, int root){
dfs2(node, 0);
vis[node] = 1;
maks3[node] = sub_maks[node];
MINI = min(MINI, maks3[node]);
for (auto i : adj[node]){
if (i.st == root) continue;
dfs3(i.st, node);
}
}
void dfs(int node, int root, int m){
vis[node] = 1;
maks[node] = max(m, sub_maks[node]);
MINI = min(MINI, maks[node]);
vector<array<int, 3>> v;
for (auto i : adj[node]){
if (i.st == root) continue;
v.pb({sub_maks[i.st] + i.nd, i.st, i.nd});
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); i++){
int to = v[i][1], w = v[i][2];
int add = m;
if (i + 1 < v.size()) add = max(add, v.back()[0]);
else add = max(add, v[v.size() - 2][0]);
dfs(to, node, add + w);
}
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
for (int i = 1; i <= N; i++){
vis[i] = 0, adj[i].clear(), maks[i] = 0, sub_maks[i] = 0, maks3[i] = 0;
}
for (int i = 0; i < M; i++){
A[i]++, B[i]++;
adj[A[i]].pb({B[i], T[i]});
adj[B[i]].pb({A[i], T[i]});
}
int ANS = 0;
priority_queue<int> q;
for (int i = 1; i <= N; i++){
if (vis[i]) continue;
MINI = modulo;
/*
dfs2(i, 0);
dfs(i, 0, 0);*/
dfs3(i, 0);
q.push(MINI);
}
for (int i = 1; i <= N; i++) ANS = max(ANS, maks3[i]);
while(!q.empty()){
int a = q.top();
q.pop();
if (q.empty()) break;
int b = q.top();
q.pop();
int neww = max(a, b + L);
ANS = max(ANS, a + b + L);
q.push(neww);
}
return ANS;
}
/*
static int A[MAX_N];
static int B[MAX_N];
static int T[MAX_N];
int main() {
int N, M, L, i;
int res;
fileio();
FILE *f = fopen("input.txt", "r");
if (!f)
fail("Failed to open input file.");
res = fscanf(f, "%d%d%d", &N, &M, &L);
for (i = 0; i < M; i++)
res = fscanf(f, "%d%d%d", &A[i], &B[i], &T[i]);
fclose(f);
int answer = travelTime(N, M, L, A, B, T);
printf("%d\n", answer);
return 0;
}
*/
Compilation message
dreaming.cpp: In function 'void dfs(int, int, int)':
dreaming.cpp:70:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
70 | for (int i = 0; i < v.size(); i++){
| ~~^~~~~~~~~~
dreaming.cpp:73:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
73 | if (i + 1 < v.size()) add = max(add, v.back()[0]);
| ~~~~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
18588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7512 KB |
Output is correct |
2 |
Correct |
3 ms |
7516 KB |
Output is correct |
3 |
Correct |
4 ms |
7516 KB |
Output is correct |
4 |
Correct |
3 ms |
7516 KB |
Output is correct |
5 |
Correct |
3 ms |
7444 KB |
Output is correct |
6 |
Correct |
3 ms |
7512 KB |
Output is correct |
7 |
Correct |
3 ms |
7516 KB |
Output is correct |
8 |
Correct |
3 ms |
7512 KB |
Output is correct |
9 |
Correct |
3 ms |
7516 KB |
Output is correct |
10 |
Correct |
4 ms |
7516 KB |
Output is correct |
11 |
Correct |
3 ms |
7516 KB |
Output is correct |
12 |
Correct |
3 ms |
7516 KB |
Output is correct |
13 |
Correct |
3 ms |
7516 KB |
Output is correct |
14 |
Correct |
3 ms |
7516 KB |
Output is correct |
15 |
Correct |
3 ms |
7492 KB |
Output is correct |
16 |
Correct |
3 ms |
7516 KB |
Output is correct |
17 |
Correct |
3 ms |
7516 KB |
Output is correct |
18 |
Correct |
3 ms |
7516 KB |
Output is correct |
19 |
Correct |
3 ms |
7516 KB |
Output is correct |
20 |
Correct |
3 ms |
7516 KB |
Output is correct |
21 |
Correct |
4 ms |
7768 KB |
Output is correct |
22 |
Correct |
3 ms |
7516 KB |
Output is correct |
23 |
Correct |
3 ms |
7516 KB |
Output is correct |
24 |
Correct |
3 ms |
7516 KB |
Output is correct |
25 |
Correct |
3 ms |
7516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
18588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
12000 KB |
Output is correct |
2 |
Correct |
24 ms |
12120 KB |
Output is correct |
3 |
Correct |
25 ms |
12000 KB |
Output is correct |
4 |
Correct |
20 ms |
12120 KB |
Output is correct |
5 |
Correct |
20 ms |
11996 KB |
Output is correct |
6 |
Correct |
21 ms |
12508 KB |
Output is correct |
7 |
Correct |
23 ms |
12252 KB |
Output is correct |
8 |
Correct |
19 ms |
12000 KB |
Output is correct |
9 |
Correct |
26 ms |
11992 KB |
Output is correct |
10 |
Correct |
20 ms |
12248 KB |
Output is correct |
11 |
Correct |
3 ms |
7512 KB |
Output is correct |
12 |
Correct |
10 ms |
9668 KB |
Output is correct |
13 |
Correct |
13 ms |
9688 KB |
Output is correct |
14 |
Correct |
10 ms |
9688 KB |
Output is correct |
15 |
Correct |
10 ms |
9688 KB |
Output is correct |
16 |
Correct |
10 ms |
9668 KB |
Output is correct |
17 |
Correct |
10 ms |
9688 KB |
Output is correct |
18 |
Correct |
10 ms |
9688 KB |
Output is correct |
19 |
Correct |
10 ms |
9668 KB |
Output is correct |
20 |
Correct |
3 ms |
7516 KB |
Output is correct |
21 |
Correct |
3 ms |
7516 KB |
Output is correct |
22 |
Correct |
4 ms |
7516 KB |
Output is correct |
23 |
Correct |
9 ms |
9688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7512 KB |
Output is correct |
2 |
Correct |
3 ms |
7516 KB |
Output is correct |
3 |
Correct |
4 ms |
7516 KB |
Output is correct |
4 |
Correct |
3 ms |
7516 KB |
Output is correct |
5 |
Correct |
3 ms |
7444 KB |
Output is correct |
6 |
Correct |
3 ms |
7512 KB |
Output is correct |
7 |
Correct |
3 ms |
7516 KB |
Output is correct |
8 |
Correct |
3 ms |
7512 KB |
Output is correct |
9 |
Correct |
3 ms |
7516 KB |
Output is correct |
10 |
Correct |
4 ms |
7516 KB |
Output is correct |
11 |
Correct |
3 ms |
7516 KB |
Output is correct |
12 |
Correct |
3 ms |
7516 KB |
Output is correct |
13 |
Correct |
3 ms |
7516 KB |
Output is correct |
14 |
Correct |
3 ms |
7516 KB |
Output is correct |
15 |
Correct |
3 ms |
7492 KB |
Output is correct |
16 |
Correct |
3 ms |
7516 KB |
Output is correct |
17 |
Correct |
3 ms |
7516 KB |
Output is correct |
18 |
Correct |
3 ms |
7516 KB |
Output is correct |
19 |
Correct |
3 ms |
7516 KB |
Output is correct |
20 |
Correct |
3 ms |
7516 KB |
Output is correct |
21 |
Correct |
4 ms |
7768 KB |
Output is correct |
22 |
Correct |
3 ms |
7516 KB |
Output is correct |
23 |
Correct |
3 ms |
7516 KB |
Output is correct |
24 |
Correct |
3 ms |
7516 KB |
Output is correct |
25 |
Correct |
3 ms |
7516 KB |
Output is correct |
26 |
Correct |
3 ms |
7516 KB |
Output is correct |
27 |
Correct |
4 ms |
7508 KB |
Output is correct |
28 |
Correct |
5 ms |
7560 KB |
Output is correct |
29 |
Correct |
3 ms |
7516 KB |
Output is correct |
30 |
Correct |
4 ms |
7512 KB |
Output is correct |
31 |
Correct |
5 ms |
7512 KB |
Output is correct |
32 |
Correct |
3 ms |
7516 KB |
Output is correct |
33 |
Correct |
4 ms |
7516 KB |
Output is correct |
34 |
Correct |
5 ms |
7516 KB |
Output is correct |
35 |
Correct |
3 ms |
7516 KB |
Output is correct |
36 |
Correct |
3 ms |
7516 KB |
Output is correct |
37 |
Correct |
3 ms |
7516 KB |
Output is correct |
38 |
Correct |
3 ms |
7412 KB |
Output is correct |
39 |
Correct |
3 ms |
7768 KB |
Output is correct |
40 |
Correct |
3 ms |
7512 KB |
Output is correct |
41 |
Correct |
3 ms |
7516 KB |
Output is correct |
42 |
Correct |
4 ms |
7488 KB |
Output is correct |
43 |
Correct |
3 ms |
7516 KB |
Output is correct |
44 |
Correct |
5 ms |
7516 KB |
Output is correct |
45 |
Correct |
3 ms |
7512 KB |
Output is correct |
46 |
Correct |
3 ms |
7516 KB |
Output is correct |
47 |
Correct |
3 ms |
7516 KB |
Output is correct |
48 |
Correct |
3 ms |
7516 KB |
Output is correct |
49 |
Correct |
3 ms |
7516 KB |
Output is correct |
50 |
Correct |
3 ms |
7516 KB |
Output is correct |
51 |
Correct |
3 ms |
7532 KB |
Output is correct |
52 |
Correct |
3 ms |
7512 KB |
Output is correct |
53 |
Correct |
3 ms |
7516 KB |
Output is correct |
54 |
Correct |
129 ms |
7896 KB |
Output is correct |
55 |
Correct |
110 ms |
8020 KB |
Output is correct |
56 |
Correct |
4 ms |
7516 KB |
Output is correct |
57 |
Correct |
3 ms |
7516 KB |
Output is correct |
58 |
Correct |
55 ms |
7772 KB |
Output is correct |
59 |
Correct |
54 ms |
7512 KB |
Output is correct |
60 |
Correct |
5 ms |
7512 KB |
Output is correct |
61 |
Correct |
4 ms |
7516 KB |
Output is correct |
62 |
Correct |
43 ms |
7760 KB |
Output is correct |
63 |
Correct |
38 ms |
7772 KB |
Output is correct |
64 |
Correct |
3 ms |
7516 KB |
Output is correct |
65 |
Correct |
4 ms |
7492 KB |
Output is correct |
66 |
Correct |
63 ms |
7516 KB |
Output is correct |
67 |
Correct |
38 ms |
7516 KB |
Output is correct |
68 |
Correct |
4 ms |
7516 KB |
Output is correct |
69 |
Correct |
4 ms |
7516 KB |
Output is correct |
70 |
Correct |
4 ms |
7508 KB |
Output is correct |
71 |
Correct |
3 ms |
7528 KB |
Output is correct |
72 |
Correct |
56 ms |
7516 KB |
Output is correct |
73 |
Correct |
58 ms |
7736 KB |
Output is correct |
74 |
Correct |
5 ms |
7516 KB |
Output is correct |
75 |
Correct |
5 ms |
7516 KB |
Output is correct |
76 |
Correct |
49 ms |
7772 KB |
Output is correct |
77 |
Correct |
71 ms |
7772 KB |
Output is correct |
78 |
Correct |
4 ms |
7516 KB |
Output is correct |
79 |
Correct |
5 ms |
7508 KB |
Output is correct |
80 |
Correct |
3 ms |
7492 KB |
Output is correct |
81 |
Correct |
4 ms |
7516 KB |
Output is correct |
82 |
Correct |
5 ms |
7560 KB |
Output is correct |
83 |
Correct |
4 ms |
7516 KB |
Output is correct |
84 |
Correct |
8 ms |
7640 KB |
Output is correct |
85 |
Correct |
3 ms |
7572 KB |
Output is correct |
86 |
Correct |
22 ms |
7688 KB |
Output is correct |
87 |
Correct |
53 ms |
7516 KB |
Output is correct |
88 |
Correct |
4 ms |
7516 KB |
Output is correct |
89 |
Correct |
4 ms |
7516 KB |
Output is correct |
90 |
Correct |
4 ms |
7524 KB |
Output is correct |
91 |
Correct |
4 ms |
7532 KB |
Output is correct |
92 |
Correct |
16 ms |
7516 KB |
Output is correct |
93 |
Correct |
18 ms |
7512 KB |
Output is correct |
94 |
Correct |
21 ms |
7512 KB |
Output is correct |
95 |
Correct |
31 ms |
7512 KB |
Output is correct |
96 |
Correct |
26 ms |
7512 KB |
Output is correct |
97 |
Correct |
26 ms |
7516 KB |
Output is correct |
98 |
Correct |
29 ms |
7516 KB |
Output is correct |
99 |
Correct |
47 ms |
7516 KB |
Output is correct |
100 |
Correct |
33 ms |
7516 KB |
Output is correct |
101 |
Correct |
35 ms |
7724 KB |
Output is correct |
102 |
Correct |
3 ms |
7516 KB |
Output is correct |
103 |
Correct |
3 ms |
7516 KB |
Output is correct |
104 |
Correct |
3 ms |
7516 KB |
Output is correct |
105 |
Correct |
3 ms |
7516 KB |
Output is correct |
106 |
Correct |
3 ms |
7516 KB |
Output is correct |
107 |
Correct |
3 ms |
7528 KB |
Output is correct |
108 |
Correct |
3 ms |
7516 KB |
Output is correct |
109 |
Correct |
3 ms |
7496 KB |
Output is correct |
110 |
Correct |
4 ms |
7516 KB |
Output is correct |
111 |
Correct |
3 ms |
7516 KB |
Output is correct |
112 |
Correct |
4 ms |
7504 KB |
Output is correct |
113 |
Correct |
7 ms |
7516 KB |
Output is correct |
114 |
Correct |
10 ms |
7516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
18588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |