Submission #660710

# Submission time Handle Problem Language Result Execution time Memory
660710 2022-11-22T20:19:23 Z BidoTeima Poklon (COCI17_poklon7) C++17
120 / 120
740 ms 56064 KB
/*
ID: BidoTeima
LANG: C++11
TASK: 
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void moo(string filename);
void ACPLS(string str = "")
{
    if(str=="NOF")return;
    if(str.size())
        moo(str);
    else{
        #ifndef ONLINE_JUDGE
            freopen("output.txt", "w", stdout);
            freopen("input.txt", "r", stdin);
        #endif
    }
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void moo(string fileName){
    freopen((fileName+".in").c_str(),"r",stdin);
    freopen((fileName+".out").c_str(),"w",stdout);
}
#define tc         \
    int tttttt/*,subtask*/;    \
    cin >> tttttt/* >> subtask*/; \
    while (tttttt--)/*end
*/
pair<int,int>adj[(int)1e6+5]; 
pair<int,int>ans={0,0};
string binary(int x){ 
    string ret;
    if(x<0)x=-x;
    if(!x)return "0";
    while(x){
        ret.push_back('0'+(x%2));
        x/=2;
    }
    reverse(ret.begin(),ret.end());
    return ret;
} 
void dfs(ll node, int d){
    if(node <= 0){
        if(node == 0)return; 
        if(log2(max(1ll,-node))+d>=log2(max(1,ans.first))+ans.second){
            ans={-node,d};
        }
        return;
    }
    dfs(adj[node].first,d+1);
    dfs(adj[node].second,d+1);
}
int main()
{
    //ACPLS();   
    int n;
    cin>>n;
    for(int i = 1; i <= n; i++){
        ll u,v;
        cin>>u>>v;
        adj[i].first=(u);
        adj[i].second=(v);
    }
    dfs(1,0);
    cout<<binary(ans.first);
    for(int i = 0; i < ans.second; i++)cout<<0;
}

Compilation message

poklon.cpp: In function 'void ACPLS(std::string)':
poklon.cpp:17:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |             freopen("output.txt", "w", stdout);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
poklon.cpp:18:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |             freopen("input.txt", "r", stdin);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
poklon.cpp: In function 'void moo(std::string)':
poklon.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((fileName+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
poklon.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((fileName+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 7 ms 468 KB Output is correct
12 Correct 9 ms 388 KB Output is correct
13 Correct 34 ms 1444 KB Output is correct
14 Correct 84 ms 2620 KB Output is correct
15 Correct 83 ms 1072 KB Output is correct
16 Correct 237 ms 6496 KB Output is correct
17 Correct 559 ms 13764 KB Output is correct
18 Correct 571 ms 15164 KB Output is correct
19 Correct 695 ms 12712 KB Output is correct
20 Correct 740 ms 56064 KB Output is correct