Submission #1120336

#TimeUsernameProblemLanguageResultExecution timeMemory
1120336vjudge1KOVANICE (COI15_kovanice)C++17
50 / 100
81 ms9860 KiB
#include <bits/stdc++.h>
using namespace std;

struct query {
  int a;
  int b;
  char c;
};

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m, v;
  cin >> n >> m >> v;
  vector<int> types(m, -1);
  vector<query> queries(v);

  for (query &q : queries) {
    cin >> q.a >> q.c >> q.b;
    q.a--;
    q.b--;
  }

  char changed;
  do {
    changed = false;

    for (const query &q : queries) {
      switch (q.c) {
      case '<':
        if (types[q.b] == -1 or types[q.a] == -1) {
          types[q.b] = 2;
          types[q.a] = 1;
          changed = true;
        }
        break;
      case '=':
        if (types[q.b] != -1 and types[q.a] == -1) {
          types[q.a] = types[q.b];
          changed = true;
        } else if (types[q.a] != -1 and types[q.b] == -1) {
          types[q.b] = types[q.a];
          changed = true;
        }
        break;
      default:
        break;
      }
    }
  } while (changed);

  for (const int &type : types) {
    if (type == -1) {
      cout << "?\n";
      continue;
    }
    cout << 'K' << type << '\n';
  }
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...