| Task: | Mobiles |
| Sender: | Lieska |
| Submission time: | 2019-03-08 10:14:36 +0200 |
| Language: | C++ |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:22:2: error: 'h' was not declared in this scope
h(1, 1);
^
input/code.cpp: At global scope:
input/code.cpp:26:20: error: expected constructor, destructor, or type conversion at end of input
__builtin_popcount()
^Code
#include <iostream>
using namespace std;
int t[100001][2];
int k, l, n, e, y;
int g(int a){
if (a==-1) return 1;
int v=g(t[a][0]);
int w=g(t[a][1]);
if (__builtin_popcount(v)!=1 && __builtin_popcount(w)!=1) e=1;
if (v<w) y++;
if (v>2*w || w>2*v) e=1;
return v+w;
}
int main(){
cin >> n;
for (int i=1; i<=n; ++i) {
cin >> k >> l;
t[i][0]=k;
t[i][1]=l;
}
g(1);
h(1, 1);
if (e) cout << "-1\n";
else cout << y << "\n";
}
__builtin_popcount()