Submission #435434

# Submission time Handle Problem Language Result Execution time Memory
435434 2021-06-23T10:16:48 Z Muhammetali Keys (IOI21_keys) C++17
20 / 100
2500 ms 45976 KB
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define sz(x) (ll)(x).size()
#define all(x) x.begin(),x.end()
#define all_r(x) x.rbegin(),x.rend()
#define clr(a) memset((a),0,sizeof(a))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef pair<ll,ll> pl;
typedef vector<ll> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef priority_queue<ll,vl,greater<ll>> pqg;
int R[300000];
vpi adj[300000];
set<int>st[300000],key;
void find(int k,int ind){
	st[ind].ins(k);
	key.ins(R[k]);
	for(int i:st[ind]){
		for(auto it:adj[i]){
			if(st[ind].count(it.ff)==1 || key.count(it.ss)==0)continue;
			find(it.ff,ind);
			return;
		}
	}
}
vector<int> find_reachable(vector<int> r,vector<int> u,vector<int> v,vector<int> c){
	int n=sz(r);
	int m=sz(u);
	vector<int> ans(n,1);
	for(int i=0;i<n;i++)R[i]=r[i];
	for(int i=0;i<m;i++){
		adj[u[i]].pb({v[i],c[i]});
		adj[v[i]].pb({u[i],c[i]});
	}
	int res=INT_MAX;
	for(int i=0;i<n;i++){
		key.clear();
		for(auto it:adj[i]){
			if(r[i]==it.ss && ans[it.ff]!=1){
				for(int j:st[it.ff])st[i].ins(j);
			}
		}
		find(i,i);
		ans[i]=sz(st[i]);
		if(res>ans[i])res=ans[i];
	}
	for(int i=0;i<n;i++){
		if(ans[i]==res)ans[i]=1;
		else ans[i]=0;
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 21324 KB Output is correct
2 Correct 15 ms 21324 KB Output is correct
3 Correct 13 ms 21324 KB Output is correct
4 Correct 37 ms 21956 KB Output is correct
5 Correct 13 ms 21324 KB Output is correct
6 Correct 15 ms 21324 KB Output is correct
7 Correct 13 ms 21432 KB Output is correct
8 Correct 22 ms 21964 KB Output is correct
9 Correct 39 ms 22452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 21324 KB Output is correct
2 Correct 15 ms 21324 KB Output is correct
3 Correct 13 ms 21324 KB Output is correct
4 Correct 37 ms 21956 KB Output is correct
5 Correct 13 ms 21324 KB Output is correct
6 Correct 15 ms 21324 KB Output is correct
7 Correct 13 ms 21432 KB Output is correct
8 Correct 22 ms 21964 KB Output is correct
9 Correct 39 ms 22452 KB Output is correct
10 Correct 41 ms 21828 KB Output is correct
11 Correct 43 ms 21928 KB Output is correct
12 Correct 49 ms 21828 KB Output is correct
13 Correct 14 ms 21352 KB Output is correct
14 Correct 14 ms 21432 KB Output is correct
15 Correct 37 ms 21836 KB Output is correct
16 Correct 14 ms 21436 KB Output is correct
17 Correct 15 ms 21436 KB Output is correct
18 Correct 14 ms 21452 KB Output is correct
19 Correct 16 ms 21432 KB Output is correct
20 Correct 14 ms 21452 KB Output is correct
21 Correct 80 ms 23404 KB Output is correct
22 Correct 22 ms 21704 KB Output is correct
23 Correct 61 ms 22364 KB Output is correct
24 Correct 59 ms 22484 KB Output is correct
25 Correct 98 ms 23084 KB Output is correct
26 Correct 91 ms 23016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 21324 KB Output is correct
2 Correct 15 ms 21324 KB Output is correct
3 Correct 13 ms 21324 KB Output is correct
4 Correct 37 ms 21956 KB Output is correct
5 Correct 13 ms 21324 KB Output is correct
6 Correct 15 ms 21324 KB Output is correct
7 Correct 13 ms 21432 KB Output is correct
8 Correct 22 ms 21964 KB Output is correct
9 Correct 39 ms 22452 KB Output is correct
10 Correct 41 ms 21828 KB Output is correct
11 Correct 43 ms 21928 KB Output is correct
12 Correct 49 ms 21828 KB Output is correct
13 Correct 14 ms 21352 KB Output is correct
14 Correct 14 ms 21432 KB Output is correct
15 Correct 37 ms 21836 KB Output is correct
16 Correct 14 ms 21436 KB Output is correct
17 Correct 15 ms 21436 KB Output is correct
18 Correct 14 ms 21452 KB Output is correct
19 Correct 16 ms 21432 KB Output is correct
20 Correct 14 ms 21452 KB Output is correct
21 Correct 80 ms 23404 KB Output is correct
22 Correct 22 ms 21704 KB Output is correct
23 Correct 61 ms 22364 KB Output is correct
24 Correct 59 ms 22484 KB Output is correct
25 Correct 98 ms 23084 KB Output is correct
26 Correct 91 ms 23016 KB Output is correct
27 Execution timed out 2600 ms 23980 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 21324 KB Output is correct
2 Correct 15 ms 21324 KB Output is correct
3 Correct 13 ms 21324 KB Output is correct
4 Correct 37 ms 21956 KB Output is correct
5 Correct 13 ms 21324 KB Output is correct
6 Correct 15 ms 21324 KB Output is correct
7 Correct 13 ms 21432 KB Output is correct
8 Correct 22 ms 21964 KB Output is correct
9 Correct 39 ms 22452 KB Output is correct
10 Execution timed out 2564 ms 45976 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 21324 KB Output is correct
2 Correct 15 ms 21324 KB Output is correct
3 Correct 13 ms 21324 KB Output is correct
4 Correct 37 ms 21956 KB Output is correct
5 Correct 13 ms 21324 KB Output is correct
6 Correct 15 ms 21324 KB Output is correct
7 Correct 13 ms 21432 KB Output is correct
8 Correct 22 ms 21964 KB Output is correct
9 Correct 39 ms 22452 KB Output is correct
10 Correct 41 ms 21828 KB Output is correct
11 Correct 43 ms 21928 KB Output is correct
12 Correct 49 ms 21828 KB Output is correct
13 Correct 14 ms 21352 KB Output is correct
14 Correct 14 ms 21432 KB Output is correct
15 Correct 37 ms 21836 KB Output is correct
16 Correct 14 ms 21436 KB Output is correct
17 Correct 15 ms 21436 KB Output is correct
18 Correct 14 ms 21452 KB Output is correct
19 Correct 16 ms 21432 KB Output is correct
20 Correct 14 ms 21452 KB Output is correct
21 Correct 80 ms 23404 KB Output is correct
22 Correct 22 ms 21704 KB Output is correct
23 Correct 61 ms 22364 KB Output is correct
24 Correct 59 ms 22484 KB Output is correct
25 Correct 98 ms 23084 KB Output is correct
26 Correct 91 ms 23016 KB Output is correct
27 Execution timed out 2600 ms 23980 KB Time limit exceeded
28 Halted 0 ms 0 KB -