Submission #521604

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5216042022-02-02 14:26:36eecsKeys (IOI21_keys)C++17
100 / 100
1644 ms53292 KiB
#include "keys.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> find_reachable(vector<int> r, vector<int> U, vector<int> V, vector<int> C) {
int n = r.size(), mn = INT_MAX;
vector<vector<array<int, 2>>> G(n);
for (int i = 0; i < U.size(); i++) {
G[U[i]].push_back({V[i], C[i]});
G[V[i]].push_back({U[i], C[i]});
}
vector<int> ans, perm(n), pos(n), cnt(n), vis(n, -1), visc(n, -1);
vector<vector<int>> cand(n);
vector<bool> solved(n);
iota(perm.begin(), perm.end(), 0);
for (int i = 0; i < n; i++) {
for (auto &e : G[i]) cnt[i] += e[1] == r[i];
}
sort(perm.begin(), perm.end(), [&](int u, int v) { return cnt[u] < cnt[v]; });
for (int i = 0; i < n; i++) {
pos[perm[i]] = i;
}
for (int i = 0; i < n; i++) {
sort(G[i].begin(), G[i].end(), [&](array<int, 2> p, array<int, 2> q) { return pos[p[0]] < pos[q[0]]; });
}
queue<int> Q;
vector<int> ver, col;
for (int x : perm) {
ver = {x}, col.clear();
while (!Q.empty()) Q.pop();
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:8:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int i = 0; i < U.size(); i++) {
      |                  ~~^~~~~~~~~~
keys.cpp:37:34: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |      if (solved[v] || ver.size() > mn) goto nxt;
      |                       ~~~~~~~~~~~^~~~
keys.cpp:44:37: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |      if (solved[e[0]] || ver.size() > mn) goto nxt;
      |                          ~~~~~~~~~~~^~~~
keys.cpp:52:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |   if (ver.size() < mn) mn = ver.size(), ans = ver;
      |       ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...