답안 #729101

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729101 2023-04-23T13:55:56 Z NeroZein Inside information (BOI21_servers) C++17
5 / 100
75 ms 2268 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 500005;

int appear[N];

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); 
  int n, k;
  cin >> n >> k;
  for (int i = 1, cnt = 0; i < n + k; ++i) {
    char c;
    cin >> c;
    if (c == 'S') {
      int a, b;
      cin >> a >> b; 
      if (a > b) swap(a, b); 
      //a == 1
      assert(a == 1); 
      cnt++;
      if (!appear[b]) appear[b] = cnt;
      if (!appear[a]) appear[a] = cnt;
    } 
    else if (c == 'C') {
      int a;
      cin >> a;
      if (!appear[a]) {
        cout << 1 << '\n'; 
      } else {
        cout << cnt - appear[a] + 2 << '\n';
      }
    } 
    else if (c == 'Q') {
      int a, b;
      cin >> a >> b;
      if (!appear[a] || !appear[b]) {
        cout << "no\n";
        continue;
      }
      bool ans = (a == 1 || appear[a] >= appear[b]);
      cout << (ans ? "yes" : "no") << '\n'; 
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 588 KB Output is correct
2 Correct 59 ms 1924 KB Output is correct
3 Correct 68 ms 1856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 588 KB Output is correct
2 Correct 59 ms 1924 KB Output is correct
3 Correct 68 ms 1856 KB Output is correct
4 Correct 25 ms 1352 KB Output is correct
5 Correct 50 ms 1908 KB Output is correct
6 Correct 75 ms 2268 KB Output is correct
7 Correct 47 ms 2032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -