Submission #706793

# Submission time Handle Problem Language Result Execution time Memory
706793 2023-03-07T17:51:57 Z EthanKim8683 Making Friends on Joitter is Fun (JOI20_joitter2) C++17
1 / 100
5000 ms 55252 KB
#include<bits/stdc++.h>
using namespace std;
using I=int;
using Lli=long long int;
const I N=100000;
set<I>incs[N],outs[N];
Lli res=0;
void add(I a,I b){
  if(a==b)return;
  if(outs[a].count(b))return;
  outs[a].insert(b);
  incs[b].insert(a);
  res++;
  vector<I>adds;
  do{
    adds.clear();
    for(auto c:outs[b]){
      if(!outs[c].count(b))continue;
      if(a==c)continue;
      if(outs[a].count(c))continue;
      adds.push_back(c);
    }
    for(auto c:adds)add(a,c);
  }while(adds.size());
  if(outs[b].count(a)){
    for(auto c:incs[a])add(c,b);
    for(auto c:incs[b])add(c,a);
  }
}
I main(){
  cin.tie(0)->sync_with_stdio(0);
  I n,m;cin>>n>>m;
  for(I i=0;i<m;i++){
    I a,b;cin>>a>>b,a--,b--;
    add(a,b);
    printf("%lli\n",res);
  }
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9684 KB Output is correct
2 Correct 7 ms 9676 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9712 KB Output is correct
6 Correct 5 ms 9812 KB Output is correct
7 Correct 20 ms 9940 KB Output is correct
8 Correct 23 ms 10144 KB Output is correct
9 Correct 27 ms 10228 KB Output is correct
10 Correct 18 ms 9924 KB Output is correct
11 Correct 19 ms 10048 KB Output is correct
12 Correct 21 ms 10032 KB Output is correct
13 Correct 21 ms 9840 KB Output is correct
14 Correct 21 ms 9940 KB Output is correct
15 Correct 16 ms 9940 KB Output is correct
16 Correct 17 ms 9868 KB Output is correct
17 Correct 17 ms 9844 KB Output is correct
18 Correct 19 ms 9960 KB Output is correct
19 Correct 18 ms 9964 KB Output is correct
20 Correct 22 ms 10060 KB Output is correct
21 Correct 25 ms 10180 KB Output is correct
22 Correct 20 ms 10044 KB Output is correct
23 Correct 25 ms 10204 KB Output is correct
24 Correct 27 ms 10108 KB Output is correct
25 Correct 25 ms 10104 KB Output is correct
26 Correct 23 ms 10100 KB Output is correct
27 Correct 28 ms 10196 KB Output is correct
28 Correct 23 ms 10068 KB Output is correct
29 Correct 23 ms 10176 KB Output is correct
30 Correct 19 ms 10000 KB Output is correct
31 Correct 20 ms 10060 KB Output is correct
32 Correct 22 ms 10028 KB Output is correct
33 Correct 23 ms 10068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9684 KB Output is correct
2 Correct 7 ms 9676 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9712 KB Output is correct
6 Correct 5 ms 9812 KB Output is correct
7 Correct 20 ms 9940 KB Output is correct
8 Correct 23 ms 10144 KB Output is correct
9 Correct 27 ms 10228 KB Output is correct
10 Correct 18 ms 9924 KB Output is correct
11 Correct 19 ms 10048 KB Output is correct
12 Correct 21 ms 10032 KB Output is correct
13 Correct 21 ms 9840 KB Output is correct
14 Correct 21 ms 9940 KB Output is correct
15 Correct 16 ms 9940 KB Output is correct
16 Correct 17 ms 9868 KB Output is correct
17 Correct 17 ms 9844 KB Output is correct
18 Correct 19 ms 9960 KB Output is correct
19 Correct 18 ms 9964 KB Output is correct
20 Correct 22 ms 10060 KB Output is correct
21 Correct 25 ms 10180 KB Output is correct
22 Correct 20 ms 10044 KB Output is correct
23 Correct 25 ms 10204 KB Output is correct
24 Correct 27 ms 10108 KB Output is correct
25 Correct 25 ms 10104 KB Output is correct
26 Correct 23 ms 10100 KB Output is correct
27 Correct 28 ms 10196 KB Output is correct
28 Correct 23 ms 10068 KB Output is correct
29 Correct 23 ms 10176 KB Output is correct
30 Correct 19 ms 10000 KB Output is correct
31 Correct 20 ms 10060 KB Output is correct
32 Correct 22 ms 10028 KB Output is correct
33 Correct 23 ms 10068 KB Output is correct
34 Correct 233 ms 11996 KB Output is correct
35 Execution timed out 5081 ms 55252 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9684 KB Output is correct
2 Correct 7 ms 9676 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9712 KB Output is correct
6 Correct 5 ms 9812 KB Output is correct
7 Correct 20 ms 9940 KB Output is correct
8 Correct 23 ms 10144 KB Output is correct
9 Correct 27 ms 10228 KB Output is correct
10 Correct 18 ms 9924 KB Output is correct
11 Correct 19 ms 10048 KB Output is correct
12 Correct 21 ms 10032 KB Output is correct
13 Correct 21 ms 9840 KB Output is correct
14 Correct 21 ms 9940 KB Output is correct
15 Correct 16 ms 9940 KB Output is correct
16 Correct 17 ms 9868 KB Output is correct
17 Correct 17 ms 9844 KB Output is correct
18 Correct 19 ms 9960 KB Output is correct
19 Correct 18 ms 9964 KB Output is correct
20 Correct 22 ms 10060 KB Output is correct
21 Correct 25 ms 10180 KB Output is correct
22 Correct 20 ms 10044 KB Output is correct
23 Correct 25 ms 10204 KB Output is correct
24 Correct 27 ms 10108 KB Output is correct
25 Correct 25 ms 10104 KB Output is correct
26 Correct 23 ms 10100 KB Output is correct
27 Correct 28 ms 10196 KB Output is correct
28 Correct 23 ms 10068 KB Output is correct
29 Correct 23 ms 10176 KB Output is correct
30 Correct 19 ms 10000 KB Output is correct
31 Correct 20 ms 10060 KB Output is correct
32 Correct 22 ms 10028 KB Output is correct
33 Correct 23 ms 10068 KB Output is correct
34 Correct 233 ms 11996 KB Output is correct
35 Execution timed out 5081 ms 55252 KB Time limit exceeded
36 Halted 0 ms 0 KB -