Submission #729098

# Submission time Handle Problem Language Result Execution time Memory
729098 2023-04-23T13:55:05 Z NeroZein Inside information (BOI21_servers) C++17
0 / 100
30 ms 588 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 = (appear[a] >= appear[b]);
      cout << (ans ? "yes" : "no") << '\n'; 
    }
  }
}
	
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -