Submission #851285

# Submission time Handle Problem Language Result Execution time Memory
851285 2023-09-19T11:08:55 Z hariaakas646 Poklon (COCI17_poklon7) C++17
0 / 120
1 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;

void usaco()
{
    freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
//    freopen("problem.out", "w", stdout);
}

vii vec;
lli tot = 0;

lli dfs(int x) {
    lli l, r;
    if(vec[x].f > 0) {
        l = dfs(vec[x].f);
    } 
    else l = abs(vec[x].f);

    if(vec[x].s > 0) {
        r = dfs(vec[x].s);
    } 
    else r = abs(vec[x].s);
    tot += max(r, l) - min(r, l);
    return 2*max(r, l);
}

int main() {
    usaco();
    int n;
    scd(n);
    vec = vii(n+1);

    forr(i, 1, n+1) {
        int l, r;
        scd(l);
        scd(r);
        vec[i] = mp(l, r);
        if(l < 0) tot += -l;
        if(r < 0) tot += -r;
    }
    dfs(1);
    string out;
    while(tot) {
        if(tot % 2 == 1) {
            out += '1';
        }
        else out += '0';
        tot /= 2;
    }
    reverse(all(out));
    bool one = false;
    for(auto e : out) {
        if(e == '1') one = true;
        if(one) cout << e;
    }
}

Compilation message

poklon.cpp: In function 'void usaco()':
poklon.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
poklon.cpp: In function 'int main()':
poklon.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
poklon.cpp:62:5: note: in expansion of macro 'scd'
   62 |     scd(n);
      |     ^~~
poklon.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
poklon.cpp:67:9: note: in expansion of macro 'scd'
   67 |         scd(l);
      |         ^~~
poklon.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
poklon.cpp:68:9: note: in expansion of macro 'scd'
   68 |         scd(r);
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 1 ms 344 KB Output isn't correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Incorrect 0 ms 344 KB Output isn't correct
13 Incorrect 0 ms 348 KB Output isn't correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Incorrect 1 ms 348 KB Output isn't correct
17 Incorrect 1 ms 348 KB Output isn't correct
18 Incorrect 0 ms 348 KB Output isn't correct
19 Incorrect 1 ms 348 KB Output isn't correct
20 Incorrect 0 ms 348 KB Output isn't correct