Submission #817448

# Submission time Handle Problem Language Result Execution time Memory
817448 2023-08-09T12:37:47 Z MohamedAhmed04 Inside information (BOI21_servers) C++14
0 / 100
47 ms 33808 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 4000 + 10 ;

int n , q ;

vector< vector<int> >adj(MAX) ;
vector<int>v[MAX] ;

int cnt[MAX] , mark[MAX][MAX] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>q ;
	for(int i = 1 ; i <= n ; ++i)
		v[i] = {i} , cnt[i] = 1 , mark[i][i] = 1 ;
	for(int i = 0 ; i < n+q-1 ; ++i)
	{
		char c ;
		cin>>c ;
		if(c == 'S')
		{
			int x , y ;
			cin>>x>>y ;
			assert(v[x].size() == 1 || v[y].size() == 1) ;
			vector<int>v2 = v[x] ;
			for(auto &j : v[y])
				v[x].push_back(j) , mark[x][j] = 1 , cnt[j]++ ;
			for(auto &j : v2)
				v[y].push_back(j) , mark[y][j] = 1 , cnt[j]++ ;

		}
		else if(c == 'Q')
		{
			int x , y ;
			cin>>x>>y ;
			if(mark[x][y])
				cout<<"yes\n" ;
			else
				cout<<"no\n" ;
		}
		else if(c == 'C')
		{
			int x ;
			cin>>x ;
			cout<<cnt[x]<<"\n" ;
		}
	}
	return 0 ;
}
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1364 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1364 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1088 KB Output is correct
2 Runtime error 47 ms 33808 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1088 KB Output is correct
2 Runtime error 47 ms 33808 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 1364 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 1364 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1364 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1364 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 1340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 1340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1364 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1364 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -