Submission #518287

# Submission time Handle Problem Language Result Execution time Memory
518287 2022-01-23T10:22:50 Z brayden04 Experimental Charges (NOI19_charges) C++14
18 / 100
101 ms 4872 KB
#include <bits/stdc++.h>
#define endl '\n'
#define int long long

using namespace std;

int N, Q;
map<int, int> charges;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  cin >> N >> Q;

  for (int i = 0; i < Q; i++){
    string T = "";
    int A = 0;
    int B = 0;
    cin >> T >> A >> B;

    if (T == "A"){
      if (charges[A] == 0 && charges[B] == 0){
        charges[A] = 1;
        charges[B] = -1;
      }
      else if (charges[A] == 1){
        charges[B] = -1;
      }
      else if (charges[A] == -1){
        charges[B] = 1;
      }
      else if (charges[B] == -1){
        charges[A] = 1;
      }
      else if (charges[B] == 1){
        charges[A] = -1;
      }
    }
    else if (T == "R"){
      if (charges[A] == 0 && charges[B] == 0){
        charges[A] = 1;
        charges[B] = 1;
      }
      else if (charges[A] == 1 && charges[B] == 0){
        charges[B] = 1;
      }
      else if (charges[A] == -1 && charges[B] == 0){
        charges[B] = -1;
      }
      else if (charges[B] == -1 && charges[A] == 0){
        charges[A] = -1;
      }
      else if (charges[B] == 1 && charges[A] == 0){
        charges[A] = 1;
      }
    }
    else if (T == "Q"){
      if (charges[A] == 0 || charges[B] == 0){
        cout << "?" << endl;
      }
      else if (charges[A] == charges[B]){
        cout << "R" << endl;
      }
      else if (charges[A] != charges[B]){
        cout << "A" << endl;
      }
    }
  }

  //cout << "----------------" << endl;

  //for (int i = 1; i <= N; i++){
    //cout << charges[i] << endl;
  //}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 80 ms 3760 KB Output is correct
2 Correct 57 ms 4100 KB Output is correct
3 Correct 63 ms 3492 KB Output is correct
4 Correct 60 ms 4028 KB Output is correct
5 Correct 67 ms 4164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 4404 KB Output is correct
2 Correct 88 ms 3840 KB Output is correct
3 Incorrect 81 ms 4872 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 82 ms 4224 KB Output is correct
2 Correct 101 ms 3772 KB Output is correct
3 Incorrect 91 ms 4544 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 80 ms 3760 KB Output is correct
7 Correct 57 ms 4100 KB Output is correct
8 Correct 63 ms 3492 KB Output is correct
9 Correct 60 ms 4028 KB Output is correct
10 Correct 67 ms 4164 KB Output is correct
11 Correct 92 ms 4404 KB Output is correct
12 Correct 88 ms 3840 KB Output is correct
13 Incorrect 81 ms 4872 KB Output isn't correct
14 Halted 0 ms 0 KB -