답안 #557938

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
557938 2022-05-06T10:19:31 Z AdamGS Inside information (BOI21_servers) C++17
5 / 100
3500 ms 10652 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=12e4+7;
vector<pair<int,int>>V[LIM];
vector<int>T;
void DFS(int x, int o, int lst) {
	T.pb(x);
	for(auto i : V[x]) if(i.st!=o && i.nd>lst) DFS(i.st, x, i.nd);
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, k, ile=0;
	cin >> n >> k;
	rep(i, n+k-1) {
		T.clear();
		char c;
		cin >> c;
		if(c=='S') {
			int a, b;
			cin >> a >> b; --a; --b;
			++ile;
			V[a].pb({b, ile});
			V[b].pb({a, ile});
		} else if(c=='Q') {
			int a, b;
			cin >> a >> b; --a; --b;
			DFS(b, b, 0);
			bool ans=false;
			for(auto j : T) if(j==a) ans=true;
			cout << (ans?"yes":"no") << '\n';
		} else {
			int a;
			cin >> a; --a;
			DFS(a, a, 0);
			cout << T.size() << '\n';
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 3824 KB Output is correct
2 Correct 52 ms 4956 KB Output is correct
3 Correct 106 ms 5068 KB Output is correct
4 Correct 38 ms 4952 KB Output is correct
5 Correct 37 ms 4976 KB Output is correct
6 Correct 1407 ms 5028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 3824 KB Output is correct
2 Correct 52 ms 4956 KB Output is correct
3 Correct 106 ms 5068 KB Output is correct
4 Correct 38 ms 4952 KB Output is correct
5 Correct 37 ms 4976 KB Output is correct
6 Correct 1407 ms 5028 KB Output is correct
7 Correct 27 ms 4300 KB Output is correct
8 Correct 39 ms 4684 KB Output is correct
9 Correct 209 ms 4852 KB Output is correct
10 Correct 33 ms 4680 KB Output is correct
11 Correct 37 ms 4596 KB Output is correct
12 Correct 1473 ms 4936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3868 KB Output is correct
2 Execution timed out 3561 ms 6044 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3868 KB Output is correct
2 Execution timed out 3561 ms 6044 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 3788 KB Output is correct
2 Correct 100 ms 10560 KB Output is correct
3 Correct 122 ms 10652 KB Output is correct
4 Execution timed out 3580 ms 8184 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 3788 KB Output is correct
2 Correct 100 ms 10560 KB Output is correct
3 Correct 122 ms 10652 KB Output is correct
4 Execution timed out 3580 ms 8184 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 3872 KB Output is correct
2 Execution timed out 3568 ms 10516 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 3872 KB Output is correct
2 Execution timed out 3568 ms 10516 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3868 KB Output is correct
2 Correct 109 ms 10632 KB Output is correct
3 Correct 118 ms 10620 KB Output is correct
4 Execution timed out 3581 ms 8140 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3868 KB Output is correct
2 Correct 109 ms 10632 KB Output is correct
3 Correct 118 ms 10620 KB Output is correct
4 Execution timed out 3581 ms 8140 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 3816 KB Output is correct
2 Correct 38 ms 4936 KB Output is correct
3 Correct 114 ms 5040 KB Output is correct
4 Correct 38 ms 5028 KB Output is correct
5 Correct 40 ms 4960 KB Output is correct
6 Correct 1427 ms 5036 KB Output is correct
7 Correct 42 ms 4316 KB Output is correct
8 Execution timed out 3546 ms 5920 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 3816 KB Output is correct
2 Correct 38 ms 4936 KB Output is correct
3 Correct 114 ms 5040 KB Output is correct
4 Correct 38 ms 5028 KB Output is correct
5 Correct 40 ms 4960 KB Output is correct
6 Correct 1427 ms 5036 KB Output is correct
7 Correct 42 ms 4316 KB Output is correct
8 Execution timed out 3546 ms 5920 KB Time limit exceeded
9 Halted 0 ms 0 KB -