Submission #2145643
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <vector> #include <string> #include <iostream> #include <algorithm> #include <map> #include <iterator> #include <functional> #include <set> #include <stack> #include <queue> #include <deque> #include <fstream> #include <iomanip> #include <numeric> #include <cmath> #include <list> #include <sstream> #include <cstring> #include <stdio.h> #include <complex> using namespace std; #pragma GCC optimize("O3") #pragma GCC target("sse4") typedef long double LD; typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int> PII; typedef pair<LD, LD> PDD; typedef pair<LL, int> PLL; typedef vector<int> VI; typedef vector<LL> VLL; typedef vector<char> VCH; typedef vector<LD> VLD; typedef vector<string> VS; typedef vector<VS> VSS; typedef vector<VI> VVI; typedef vector<VLL> VVLL; typedef vector<VCH> VVCH; typedef vector<PII> VPII; typedef vector<PLL> VPLL; typedef vector<PDD> VPDD; #define MP make_pair #define PB push_back #define X first #define Y second #define next fake_next #define prev fake_prev #define left fake_left #define right fake_right #define FOR(i,a,b) for(int i = (a); i < (b); ++i) #define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i) #define REP(i, t) FOR(i,0,t) #define ALL(a) a.begin(), a.end() #define SZ(a) (int)((a).size()) #define FILL(a, value) memset(a, value, sizeof(a)) const LD PI = acos(-1.0); const LD EPS = 1e-4; const LL INF = 1e7 - 1; const LL mod = 1000000007; const LL LINF = 1e18 + 10; const int MAXN = 100001; const int MAXK = 101; int n; VVI g; VI a; bool dfs(int v, int p) { if (p != -1 && a[v] >= a[p]) return 1; bool res = 0; for (auto i : g[v]) { if (i == p) continue; res |= !dfs(i, v); } return res; } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); //freopen("In.txt", "r", stdin); cin >> n; a.resize(n); g.resize(n); int u, v; FOR(i, 0, n) cin >> a[i]; FOR(i, 0, n - 1) { cin >> u >> v; --u; --v; g[u].push_back(v); g[v].push_back(u); } FOR(i, 0, n) if (dfs(i, -1)) cout << i + 1 << " "; cin >> n; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Tree Game |
User | vjudge1 |
Language | C++14 (GCC 5.4.1) |
Score | 1600 |
Code Size | 2109 Byte |
Status | AC |
Exec Time | 47 ms |
Memory | 512 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1600 / 1600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in38.txt, in39.txt, in4.txt, in40.txt, in41.txt, in42.txt, in43.txt, in44.txt, in45.txt, in46.txt, in47.txt, in48.txt, in49.txt, in5.txt, in50.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 3 ms | 460 KB |
in10.txt | AC | 3 ms | 460 KB |
in11.txt | AC | 3 ms | 460 KB |
in12.txt | AC | 2 ms | 384 KB |
in13.txt | AC | 2 ms | 384 KB |
in14.txt | AC | 3 ms | 460 KB |
in15.txt | AC | 3 ms | 460 KB |
in16.txt | AC | 3 ms | 460 KB |
in17.txt | AC | 3 ms | 460 KB |
in18.txt | AC | 3 ms | 460 KB |
in19.txt | AC | 3 ms | 460 KB |
in2.txt | AC | 3 ms | 460 KB |
in20.txt | AC | 3 ms | 460 KB |
in21.txt | AC | 3 ms | 384 KB |
in22.txt | AC | 3 ms | 464 KB |
in23.txt | AC | 3 ms | 464 KB |
in24.txt | AC | 3 ms | 384 KB |
in25.txt | AC | 3 ms | 384 KB |
in26.txt | AC | 3 ms | 464 KB |
in27.txt | AC | 3 ms | 384 KB |
in28.txt | AC | 3 ms | 464 KB |
in29.txt | AC | 3 ms | 464 KB |
in3.txt | AC | 3 ms | 460 KB |
in30.txt | AC | 3 ms | 464 KB |
in31.txt | AC | 35 ms | 512 KB |
in32.txt | AC | 20 ms | 512 KB |
in33.txt | AC | 33 ms | 512 KB |
in34.txt | AC | 47 ms | 512 KB |
in35.txt | AC | 29 ms | 512 KB |
in36.txt | AC | 1 ms | 256 KB |
in37.txt | AC | 1 ms | 256 KB |
in38.txt | AC | 1 ms | 256 KB |
in39.txt | AC | 1 ms | 256 KB |
in4.txt | AC | 3 ms | 460 KB |
in40.txt | AC | 2 ms | 460 KB |
in41.txt | AC | 2 ms | 460 KB |
in42.txt | AC | 2 ms | 460 KB |
in43.txt | AC | 2 ms | 460 KB |
in44.txt | AC | 2 ms | 460 KB |
in45.txt | AC | 2 ms | 384 KB |
in46.txt | AC | 2 ms | 384 KB |
in47.txt | AC | 3 ms | 384 KB |
in48.txt | AC | 3 ms | 460 KB |
in49.txt | AC | 3 ms | 460 KB |
in5.txt | AC | 2 ms | 384 KB |
in50.txt | AC | 3 ms | 460 KB |
in6.txt | AC | 3 ms | 460 KB |
in7.txt | AC | 3 ms | 460 KB |
in8.txt | AC | 3 ms | 460 KB |
in9.txt | AC | 3 ms | 460 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |