# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
408745 |
2021-05-19T15:14:39 Z |
LptN21 |
Poklon (COCI17_poklon7) |
C++14 |
|
586 ms |
170408 KB |
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define FF first
#define SS second
#define pb push_back
#define sz(x) (int)x.size()
#define oo 1e18
#define eps 1e-9
#define PI acos(-1.0)
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
const int N = 1e6+7, M=20+7;
const int MOD = 1e9+7;
int n, m, k, t;
ll ans=0;
int val[N*3];
vector<int> adj[N*3];
void dfs(int u, int depth=0) {
if(!sz(adj[u])) {
ans=max(ans, 1LL*val[u]*(1<<depth));
return;
}
for(int v, i=0;i<sz(adj[u]);i++) v=adj[u][i], dfs(v, depth+1);
}
void print() {
vector<int> s;
while(ans) s.pb(ans&1LL), ans>>=1LL;
for(int i=sz(s)-1;i>=0;i--) printf("%d", s[i]);
}
signed main() {
//freopen("test.inp", "r", stdin);
//freopen("test.out", "w", stdout);
//fastIO;
scanf("%d", &n);
int u, v, r=n;
for(int i=1;i<=n;i++) {
scanf("%d%d", &u, &v);
if(u<0) {
val[++r]=-u;
adj[i].pb(r);
} else adj[i].pb(u);
if(v<0) {
val[++r]=-v;
adj[i].pb(r);
} else adj[i].pb(v);
}
dfs(1), print();
return 0;
}
/* stuff you should look for
- int overflow, array bounds
- special cases (n=1?)
- do smth instead of do nothing and stay organized
- WRITE STUFF DOWN
- DONT JUST STICK ON ONE APPROACH
*/
Compilation message
poklon.cpp: In function 'int main()':
poklon.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
42 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
poklon.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
45 | scanf("%d%d", &u, &v);
| ~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
70756 KB |
Output is correct |
2 |
Correct |
39 ms |
70724 KB |
Output is correct |
3 |
Correct |
41 ms |
70624 KB |
Output is correct |
4 |
Correct |
39 ms |
70732 KB |
Output is correct |
5 |
Correct |
39 ms |
70728 KB |
Output is correct |
6 |
Correct |
42 ms |
70736 KB |
Output is correct |
7 |
Correct |
39 ms |
70688 KB |
Output is correct |
8 |
Correct |
40 ms |
70736 KB |
Output is correct |
9 |
Incorrect |
40 ms |
70732 KB |
Output isn't correct |
10 |
Incorrect |
39 ms |
70732 KB |
Output isn't correct |
11 |
Incorrect |
44 ms |
71396 KB |
Output isn't correct |
12 |
Incorrect |
46 ms |
71512 KB |
Output isn't correct |
13 |
Incorrect |
74 ms |
74384 KB |
Output isn't correct |
14 |
Incorrect |
89 ms |
78292 KB |
Output isn't correct |
15 |
Incorrect |
89 ms |
75844 KB |
Output isn't correct |
16 |
Incorrect |
215 ms |
94296 KB |
Output isn't correct |
17 |
Incorrect |
448 ms |
124388 KB |
Output isn't correct |
18 |
Incorrect |
456 ms |
126788 KB |
Output isn't correct |
19 |
Incorrect |
586 ms |
131772 KB |
Output isn't correct |
20 |
Incorrect |
524 ms |
170408 KB |
Output isn't correct |