제출 #1235758

#제출 시각아이디문제언어결과실행 시간메모리
1235758lechaaPoklon (COCI17_poklon7)C++20
48 / 120
210 ms125432 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long vector<vector<int>> g; vector<pair<int, int>> v; void dfs(int k, int p){ for(int y = 0; y < g[k].size(); y++){ dfs(g[k][y], k); } if(p == -1) return; if(v[p].first == 0){ v[p].first += max(v[k].first, v[k].second)*2; }else{ v[p].second += max(v[k].first, v[k].second)*2; } } main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; g.resize(n+1); v.resize(n+1); vector<int> b(n+1); for(int i = 1; i <= n; i++){ int a, b; cin >> a >> b; if(a > 0){ g[i].push_back(a); }else{ v[i].first = abs(a); } if(b > 0){ g[i].push_back(b); }else{ v[i].second = abs(b); } } dfs(1, -1); int j = max(v[1].first, v[1].second)*2; string ns = ""; while(j > 0){ if(j%2 == 1){ ns += '1'; }else{ ns += '0'; } j/=2; } reverse(ns.begin(), ns.end()); cout << ns << "\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

poklon.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...