QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#796645 | #7604. Find the Vertex | Cookie_Creamm | RE | 0ms | 0kb | C++20 | 1.7kb | 2024-12-01 23:06:06 | 2024-12-01 23:06:06 |
answer
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vt vector
#define pb push_back
#define pii pair<int, int>
#define sz(dq) (int)dq.size()
#define forr(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pll pair<ll, ll>
#define mpp make_pair
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define ld long double
ifstream fin("store.inp");
ofstream fout("store.out");
const ll mxn = 5e5 + 5, inf = 1e9, mod = 998244353, sq = 800, mxv = 1e6 + 5, pr = 37, mod2 = 1e9 + 9, mod3 = 998244353;
//const int x[4] = {0, -1, 0, 1};
const int x[4] = {1, -1, 0, 0};
const int y[4] = {0, 0, 1, -1};
//const char dir[4] = {'D', 'U', 'R', 'L'};
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
using u64 = uint64_t;
using u128 = __uint128_t;
int n, m;
int d[mxn + 1];
vt<int>adj[mxn + 1];
void solve(){
cin >> n >> m;
for(int i = 1; i <= n; i++)cin >> d[i];
for(int i = 0; i < m; i++){
int u, v; cin >> u >> v;
adj[u].pb(v); adj[v].pb(u);
}
for(int i = 1; i <= n; i++){
if(d[i] == 0){
bool bad = 0;
for(auto j: adj[i]){
if(d[j] != 1){
bad = 1; break;
}
}
if(!bad){
cout << i; return;
}
}
}
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("ARRAY.inp", "r", stdin);
//freopen("ARRAY.out", "w", stdout);
int tt; tt = 1;
while(tt--){
solve();
}
return(0);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
5 6 1 0 1 1 2 5 4 1 2 3 2 3 4 4 2 1 5