Submission #618900

# Submission time Handle Problem Language Result Execution time Memory
618900 2022-08-02T08:16:28 Z errorgorn Making Friends on Joitter is Fun (JOI20_joitter2) C++17
1 / 100
5000 ms 340 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define endl '\n'

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (int x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n,m;
bool has[55][55];

signed main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>n>>m;
	
	int a,b;
	int ans=0;
	
	while (m--){
		cin>>a>>b;
		
		if (!has[a][b]){
			has[a][b]=true;
			ans++;
			
			while (true){
				bool done=true;
				
				rep(x,1,n+1) rep(y,1,n+1) rep(z,1,n+1) if (x!=z){
					if (has[x][y] && has[y][z] && has[z][y] && !has[x][z]){
						has[x][z]=true;
						ans++;
						done=false;
					}
				}
				
				if (done) break;
			}
		}
		
		cout<<ans<<endl;
	}
	
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 232 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 56 ms 340 KB Output is correct
8 Correct 38 ms 332 KB Output is correct
9 Correct 37 ms 336 KB Output is correct
10 Correct 35 ms 212 KB Output is correct
11 Correct 45 ms 304 KB Output is correct
12 Correct 35 ms 308 KB Output is correct
13 Correct 36 ms 212 KB Output is correct
14 Correct 39 ms 308 KB Output is correct
15 Correct 36 ms 304 KB Output is correct
16 Correct 35 ms 304 KB Output is correct
17 Correct 40 ms 212 KB Output is correct
18 Correct 39 ms 308 KB Output is correct
19 Correct 37 ms 212 KB Output is correct
20 Correct 53 ms 308 KB Output is correct
21 Correct 49 ms 336 KB Output is correct
22 Correct 65 ms 304 KB Output is correct
23 Correct 33 ms 320 KB Output is correct
24 Correct 40 ms 312 KB Output is correct
25 Correct 37 ms 328 KB Output is correct
26 Correct 21 ms 328 KB Output is correct
27 Correct 20 ms 212 KB Output is correct
28 Correct 25 ms 328 KB Output is correct
29 Correct 33 ms 308 KB Output is correct
30 Correct 28 ms 212 KB Output is correct
31 Correct 40 ms 336 KB Output is correct
32 Correct 36 ms 308 KB Output is correct
33 Correct 29 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 232 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 56 ms 340 KB Output is correct
8 Correct 38 ms 332 KB Output is correct
9 Correct 37 ms 336 KB Output is correct
10 Correct 35 ms 212 KB Output is correct
11 Correct 45 ms 304 KB Output is correct
12 Correct 35 ms 308 KB Output is correct
13 Correct 36 ms 212 KB Output is correct
14 Correct 39 ms 308 KB Output is correct
15 Correct 36 ms 304 KB Output is correct
16 Correct 35 ms 304 KB Output is correct
17 Correct 40 ms 212 KB Output is correct
18 Correct 39 ms 308 KB Output is correct
19 Correct 37 ms 212 KB Output is correct
20 Correct 53 ms 308 KB Output is correct
21 Correct 49 ms 336 KB Output is correct
22 Correct 65 ms 304 KB Output is correct
23 Correct 33 ms 320 KB Output is correct
24 Correct 40 ms 312 KB Output is correct
25 Correct 37 ms 328 KB Output is correct
26 Correct 21 ms 328 KB Output is correct
27 Correct 20 ms 212 KB Output is correct
28 Correct 25 ms 328 KB Output is correct
29 Correct 33 ms 308 KB Output is correct
30 Correct 28 ms 212 KB Output is correct
31 Correct 40 ms 336 KB Output is correct
32 Correct 36 ms 308 KB Output is correct
33 Correct 29 ms 332 KB Output is correct
34 Execution timed out 5005 ms 280 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 232 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 56 ms 340 KB Output is correct
8 Correct 38 ms 332 KB Output is correct
9 Correct 37 ms 336 KB Output is correct
10 Correct 35 ms 212 KB Output is correct
11 Correct 45 ms 304 KB Output is correct
12 Correct 35 ms 308 KB Output is correct
13 Correct 36 ms 212 KB Output is correct
14 Correct 39 ms 308 KB Output is correct
15 Correct 36 ms 304 KB Output is correct
16 Correct 35 ms 304 KB Output is correct
17 Correct 40 ms 212 KB Output is correct
18 Correct 39 ms 308 KB Output is correct
19 Correct 37 ms 212 KB Output is correct
20 Correct 53 ms 308 KB Output is correct
21 Correct 49 ms 336 KB Output is correct
22 Correct 65 ms 304 KB Output is correct
23 Correct 33 ms 320 KB Output is correct
24 Correct 40 ms 312 KB Output is correct
25 Correct 37 ms 328 KB Output is correct
26 Correct 21 ms 328 KB Output is correct
27 Correct 20 ms 212 KB Output is correct
28 Correct 25 ms 328 KB Output is correct
29 Correct 33 ms 308 KB Output is correct
30 Correct 28 ms 212 KB Output is correct
31 Correct 40 ms 336 KB Output is correct
32 Correct 36 ms 308 KB Output is correct
33 Correct 29 ms 332 KB Output is correct
34 Execution timed out 5005 ms 280 KB Time limit exceeded
35 Halted 0 ms 0 KB -