Submission #1094522
Source Code Expand
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include <random>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
int n;
vi x; vvi to;
bool dfs(int v, int p=-1) {
rep(i,sz(to[v])) {
int u = to[v][i];
if (u == p) continue;
if (x[v] <= x[u]) continue;
if (!dfs(u,v)) return true;
}
return false;
}
int main() {
scanf("%d",&n);
to = vvi(n);
x = vi(n);
rep(i,n) scanf("%d",&x[i]);
rep(i,n-1) {
int a,b;
scanf("%d%d",&a,&b);
--a; --b;
to[a].pb(b);
to[b].pb(a);
}
vi ans;
rep(i,n) {
if (dfs(i)) ans.pb(i+1);
}
cout<<ans<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
F - Tree Game |
User |
snuke |
Language |
C++14 (GCC 5.4.1) |
Score |
1600 |
Code Size |
2708 Byte |
Status |
AC |
Exec Time |
4 ms |
Memory |
512 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:79:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:82:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,n) scanf("%d",&x[i]);
^
./Main.cpp:85:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&a,&b);
^
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 |
Case Name |
Status |
Exec Time |
Memory |
in1.txt |
AC |
4 ms |
512 KB |
in10.txt |
AC |
4 ms |
512 KB |
in11.txt |
AC |
4 ms |
512 KB |
in12.txt |
AC |
3 ms |
256 KB |
in13.txt |
AC |
3 ms |
256 KB |
in14.txt |
AC |
4 ms |
512 KB |
in15.txt |
AC |
4 ms |
512 KB |
in16.txt |
AC |
4 ms |
512 KB |
in17.txt |
AC |
4 ms |
512 KB |
in18.txt |
AC |
4 ms |
512 KB |
in19.txt |
AC |
4 ms |
512 KB |
in2.txt |
AC |
4 ms |
512 KB |
in20.txt |
AC |
4 ms |
512 KB |
in21.txt |
AC |
4 ms |
512 KB |
in22.txt |
AC |
4 ms |
512 KB |
in23.txt |
AC |
4 ms |
512 KB |
in24.txt |
AC |
4 ms |
512 KB |
in25.txt |
AC |
4 ms |
512 KB |
in26.txt |
AC |
4 ms |
512 KB |
in27.txt |
AC |
4 ms |
512 KB |
in28.txt |
AC |
4 ms |
512 KB |
in29.txt |
AC |
4 ms |
512 KB |
in3.txt |
AC |
4 ms |
512 KB |
in30.txt |
AC |
4 ms |
512 KB |
in31.txt |
AC |
4 ms |
384 KB |
in32.txt |
AC |
4 ms |
384 KB |
in33.txt |
AC |
4 ms |
384 KB |
in34.txt |
AC |
4 ms |
384 KB |
in35.txt |
AC |
4 ms |
384 KB |
in36.txt |
AC |
3 ms |
256 KB |
in37.txt |
AC |
2 ms |
256 KB |
in38.txt |
AC |
3 ms |
256 KB |
in39.txt |
AC |
2 ms |
256 KB |
in4.txt |
AC |
4 ms |
512 KB |
in40.txt |
AC |
4 ms |
512 KB |
in41.txt |
AC |
4 ms |
512 KB |
in42.txt |
AC |
4 ms |
512 KB |
in43.txt |
AC |
4 ms |
512 KB |
in44.txt |
AC |
4 ms |
512 KB |
in45.txt |
AC |
4 ms |
384 KB |
in46.txt |
AC |
4 ms |
384 KB |
in47.txt |
AC |
4 ms |
512 KB |
in48.txt |
AC |
4 ms |
512 KB |
in49.txt |
AC |
4 ms |
512 KB |
in5.txt |
AC |
4 ms |
384 KB |
in50.txt |
AC |
4 ms |
512 KB |
in6.txt |
AC |
4 ms |
512 KB |
in7.txt |
AC |
4 ms |
512 KB |
in8.txt |
AC |
4 ms |
512 KB |
in9.txt |
AC |
4 ms |
512 KB |
sample1.txt |
AC |
3 ms |
256 KB |
sample2.txt |
AC |
3 ms |
256 KB |
sample3.txt |
AC |
3 ms |
256 KB |