Submission #846160

# Submission time Handle Problem Language Result Execution time Memory
846160 2023-09-07T12:00:33 Z vjudge1 KOVANICE (COI15_kovanice) C++17
0 / 100
2000 ms 45252 KB
// clang-format off
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define lg2(x) (63 - __builtin_clzll(x))
#define db cerr << "BREAK\n"
#define fp(...) fprintf(stderr, __VA_ARGS__)
#define rs(a) a.resize(n)
#define hizli cin.tie(0);ios_base::sync_with_stdio(0)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(a, b) for (int a = 0; a < b; a++)
#define af(x) for(auto&a:x)fp("%d ",a);fp("\n")
#define ff first
#define ss second
#define job main
// clang-format on
template <typename... Args> void in(Args &&...args) {
  (std::cin >> ... >> args);
}
const int N = 2e5 + 5, MOD = 1e9 + 7;
/*
~Y .5. J~ ~J .5. 5: 77 :5  5: ?! ^Y ~J .5. Y^ ~? .5..Y^ !? .
^J .5. ?! ^J .5. Y: !7 :P^^G~.J7 ^Y ~J .5. Y^ ~J .5..Y^ 7? .
^Y .5. ?! ~J .5. Y^.Y##&&&@@&&&&G55 ^J .5. J~ ~? .5. Y~ !J .
^Y .5. J! ~J .5. 5#&@@@&&&@&@@@@@@&J!J .5. J~ ~J .5. Y^ !J .
:Y  5: ?! :Y .5^5&@@@@&&&&&&&@@@@&@@&5 .5. J~ ~J .5. Y~ ~Y .
:5  5: ?! ^Y  P&@&&&&&&&&&&&&&&&&&&&&&!.P. Y~ ^J .5. Y~ ~J..
.5. Y: 77 ^Y .B&&&&&&&&&&&&&&B5YYG&&&@&:5. J! ~Y .5. J~ ~J .
.5. Y^ 77 ^Y ?&&&&&&&&&&&B5J7!7??JP&&@@YY. ?! ~Y .5. Y~ ~Y .
.5  Y^ !7 ^Y J#BP5555B#G7~~~!!7?JY5B@@@P5: J! ~J .P. J~ ~J..
.5  5: 7? ^Y ~&#5J?7!7?!!77!!!!7?J5P#@@BG! Y! !Y .P. J~ ~J .
.5  Y^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&&&&@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&&@&@@*/

vector<unordered_set<int>> adj;
vector<int> val;

int n, m, v;

bool dfs(int node, int depth = 1) {
  bool is = false;
  if (depth == n) {
    is = true;
    val[node] = depth;
    return is;
  }
  if (adj[node].empty()) {
    return is;
  }
  for (auto &child : adj[node]) {
    if (dfs(child, depth + 1) && val[child] == depth + 1) {
      val[node] = depth;
      is = true;
    }
  }
  return is;
}

int job() {
  in(n, m, v);
  adj.resize(m);
  val.resize(m);
  vector<pair<int, int>> tobemerged;
  for (int i = 0; i < v; i++) {
    int a, b;
    char c;
    in(a, c, b);
    a--, b--;
    if (c == '=') {
      tobemerged.pb({a, b});
    } else if (c == '<') {
      adj[b].insert(a);
    } else {
      adj[a].insert(b);
    }
  }
  for (auto &a : tobemerged) {
    adj[a.ff].merge(adj[a.ss]);
    adj[a.ss].merge(adj[a.ff]);
  }
  for (int i = 0; i < m; i++) {
    dfs(i);
  }
  for (int i = 0; i < n; i++) {
    for (auto &a : tobemerged) {
      int mx = max(val[a.ff], val[a.ss]);
      val[a.ff] = mx;
      val[a.ss] = mx;
    }
  }
  for (auto &a : val) {
    cout << "K" << n+1-a << endl;
  }
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 308 ms 20812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 5456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2035 ms 45252 KB Time limit exceeded
2 Halted 0 ms 0 KB -