답안 #837928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
837928 2023-08-25T20:25:51 Z MohamedAhmed04 조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2) C++14
0 / 100
5000 ms 5120 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n , m ;

set<int>adj[MAX] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m ;
	for(int i = 0 ; i < m ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		adj[x].insert(y) ;
		bool ok = false ;
		while(!ok)
		{
			ok = true ;
			for(int i = 1 ; i <= n ; ++i)
			{
				for(auto &j : adj[i])
				{
					for(auto &k : adj[j])
					{
						if(adj[k].find(j) != adj[k].end() && i != k && adj[i].find(k) == adj[i].end())
							adj[i].insert(k) , ok = false ;
					}
				}
			}
		}
		int ans = 0 ;
		for(int i = 1 ; i <= n ; ++i)
			ans += adj[i].size() ;
		cout<<ans<<"\n" ;
	}
	return 0 ;
}		
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Execution timed out 5022 ms 5120 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Execution timed out 5022 ms 5120 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Execution timed out 5022 ms 5120 KB Time limit exceeded
8 Halted 0 ms 0 KB -