# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
495622 |
2021-12-19T14:30:40 Z |
PedroBigMan |
Keys (IOI21_keys) |
C++17 |
|
3000 ms |
33416 KB |
/*
Author of all code: Pedro BIGMAN Dias
Last edit: 15/02/2021
*/
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 500000000LL
#define EPS 0.00000001
#define pi 3.14159
#define VV(vvvv,NNNN,xxxx); REP(i,0,NNNN) {vvvv.pb(xxxx);}
ll mod=1000000007LL;
template<class A=ll>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}
template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}}
ll N,M; vector<bool> key; vector<vector<ll> > nxt; vector<vector<pl> > adj; vector<ll> r; vector<bool> visited; vector<ll> newkeys;
ll nei; vector<ll> newnewkeys;
void Reset()
{
REP(i,0,N) {key[i]=false; nxt[i].clear(); visited[i]=false;}
newkeys.clear();
}
void DFS(ll s)
{
if(visited[s]) {return;}
visited[s]=true; if(!key[r[s]]) {key[r[s]]=true; newnewkeys.pb(r[s]);}
REP(i,0,adj[s].size())
{
nei=adj[s][i].ff;
if(visited[nei]) {continue;}
if(key[adj[s][i].ss]) {DFS(nei);}
else {nxt[adj[s][i].ss].pb(nei);}
}
}
vector<ll> find_reachable(vector<ll> rr, vector<ll> u, vector<ll> v, vector<ll> c)
{
r=rr; N = r.size(); M = u.size(); VV(key,N,false); VV(adj,N,{});
REP(i,0,M) {adj[u[i]].pb({v[i],c[i]}); adj[v[i]].pb({u[i],c[i]});}
vector<ll> p; VV(p,N,0); VV(nxt,N,{}); VV(visited,N,false);
REP(s,0,N)
{
Reset();
visited[s]=true;
REP(i,0,adj[s].size()) {nei=adj[s][i].ff; nxt[adj[s][i].ss].pb(nei);}
newkeys.pb(r[s]); key[r[s]]=true;
while(1>0)
{
if(newkeys.size()==0) {break;}
REP(i,0,newkeys.size())
{
REP(j,0,nxt[newkeys[i]].size()) {DFS(nxt[newkeys[i]][j]);}
}
newkeys=newnewkeys; newnewkeys.clear();
}
REP(i,0,N) {if(visited[i]) {p[s]++;}}
}
ll me = *min_element(whole(p));
vector<ll> ans; VV(ans,N,0); REP(i,0,N) {if(p[i]==me) {ans[i]=1;}}
return ans;
}
Compilation message
keys.cpp:5: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
5 | #pragma GCC optimization ("O3")
|
keys.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
6 | #pragma GCC optimization ("unroll-loops")
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Correct |
0 ms |
272 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Correct |
0 ms |
272 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
2 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
2 ms |
296 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Correct |
0 ms |
272 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
2 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
2 ms |
296 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
54 ms |
616 KB |
Output is correct |
28 |
Correct |
52 ms |
624 KB |
Output is correct |
29 |
Correct |
52 ms |
632 KB |
Output is correct |
30 |
Correct |
29 ms |
448 KB |
Output is correct |
31 |
Correct |
4 ms |
332 KB |
Output is correct |
32 |
Correct |
2 ms |
296 KB |
Output is correct |
33 |
Correct |
3 ms |
332 KB |
Output is correct |
34 |
Correct |
21 ms |
468 KB |
Output is correct |
35 |
Correct |
24 ms |
428 KB |
Output is correct |
36 |
Correct |
108 ms |
652 KB |
Output is correct |
37 |
Correct |
99 ms |
636 KB |
Output is correct |
38 |
Correct |
160 ms |
672 KB |
Output is correct |
39 |
Correct |
145 ms |
684 KB |
Output is correct |
40 |
Correct |
8 ms |
432 KB |
Output is correct |
41 |
Correct |
37 ms |
556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Correct |
0 ms |
272 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Execution timed out |
3027 ms |
33416 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Correct |
0 ms |
272 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
2 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
2 ms |
296 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
54 ms |
616 KB |
Output is correct |
28 |
Correct |
52 ms |
624 KB |
Output is correct |
29 |
Correct |
52 ms |
632 KB |
Output is correct |
30 |
Correct |
29 ms |
448 KB |
Output is correct |
31 |
Correct |
4 ms |
332 KB |
Output is correct |
32 |
Correct |
2 ms |
296 KB |
Output is correct |
33 |
Correct |
3 ms |
332 KB |
Output is correct |
34 |
Correct |
21 ms |
468 KB |
Output is correct |
35 |
Correct |
24 ms |
428 KB |
Output is correct |
36 |
Correct |
108 ms |
652 KB |
Output is correct |
37 |
Correct |
99 ms |
636 KB |
Output is correct |
38 |
Correct |
160 ms |
672 KB |
Output is correct |
39 |
Correct |
145 ms |
684 KB |
Output is correct |
40 |
Correct |
8 ms |
432 KB |
Output is correct |
41 |
Correct |
37 ms |
556 KB |
Output is correct |
42 |
Execution timed out |
3027 ms |
33416 KB |
Time limit exceeded |
43 |
Halted |
0 ms |
0 KB |
- |