Submission #496559

# Submission time Handle Problem Language Result Execution time Memory
496559 2021-12-21T14:17:47 Z Nuraly_Serikbay Valley (BOI19_valley) C++14
0 / 100
14 ms 1356 KB
#include <bits/stdc++.h>
  
#define endl "\n"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz size()
#define rep(i,k,n) for(int i = k ; i <= n ; ++i)
#define per(i,k,n) for(int i = k ; i >= n ; --i)
#define Zymraq() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define fr(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define toqta return 0
#define PERMUTE next_permutation
#define no cout<<"No"<<endl;
#define yes cout<<"Yes"<<endl;
#define a() a + 1, a + n + 1  
 
  
using namespace std;
   
typedef long long ll;
typedef unsigned long long ull;
typedef string S;
typedef double ld;
typedef long double lld;
   
const int N = 1e6 + 17;
const int modd = 1e9 + 7;
const int INF = 1e9 - 19;
const int P = 37;
const ll NN = 1e7 + 17;
const ld eps = 1e-19;
const double pi = 3.141592653589793238462643383279 ;
   
 
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second < b.second);
}
 
void pre (ll a) {
    cout << fixed << setprecision(a);
    return;
}
 
ll n, s, q, e; 
vector <ll> g[10001];
ll dist[10001][10001], l, r;
vector <pair <ll, ll>> reb;
bool ok;
bool block[10001][10001];

void dfs (ll v, ll pr) {
	if (v == r) ok = 1;
	for (auto to: g[v]) {
		if (pr != to && !block[v][to]) dfs (to, v);
	}
	return;
}

void solve() {
	cin >> n >> s >> q >> e;
	for (int i = 1; i < n; ++ i) {
		ll x, y, d;
		cin >> x >> y >> d;
		g[x].pb (y);
		g[y].pb (x);
		dist[x][y] = d;
		dist[y][x] = d;
		reb.pb (mp(x, y));		
	}	
	for (int i = 1; i <= s; ++ i) {
		ll x;
		cin >> x;
	}
	while (q --) {
		cin >> l >> r;
		ok = 0;		
		block[reb[l - 1].F][reb[l - 1].S] = 1;
		block[reb[l - 1].S][reb[l - 1].F] = 1;
		dfs (e, -1);	
		if (ok) cout << "escape\n";
		else cout << 0 << '\n';
		block[reb[l - 1].F][reb[l - 1].S] = 0;
		block[reb[l - 1].S][reb[l - 1].F] = 0;	
	}
	return;
}
 
int main() {
	Zymraq ();	
	solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1356 KB Output isn't correct
2 Halted 0 ms 0 KB -