Last active
July 15, 2019 05:20
-
-
Save surinoel/d29a1bb83c3067487fa9ee5bc15a9322 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <queue> | |
#include <cstring> | |
#include <iostream> | |
using namespace std; | |
struct tree { | |
int p; | |
int left, right; | |
tree() : p(-1) {} | |
tree(int p, int left, int right) : p(p), left(left), right(right) {} | |
}; | |
tree tr[10001]; | |
int coldata[10001]; | |
int col = 1; | |
int main(void) { | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
int n; | |
cin >> n; | |
for (int i = 1; i <= n; i++) { | |
int p, l, r; | |
tr[p].left = l, tr[p].right = r; // CL.exe | |
tr[l].p = p, tr[r].p = p; | |
} | |
int root; | |
for (int i = 1; i <= n; i++) { | |
if (tr[i].p == -1) { | |
root = i; | |
} | |
} | |
cout << root << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment