Submission #852876

# Submission time Handle Problem Language Result Execution time Memory
852876 2023-09-23T03:17:06 Z 12345678 Werewolf (IOI18_werewolf) C++17
0 / 100
142 ms 40400 KB
#include "werewolf.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=3e3+5;
int dsu[nx];
vector<tuple<int, int, int>> dmn, dmx;

int find(int x)
{
  if (dsu[x]==x) return x;
  return dsu[x]=find(dsu[x]);
}

std::vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y,
                                std::vector<int> S, std::vector<int> E,
                                std::vector<int> L, std::vector<int> R) {
  for (int i=0; i<X.size(); i++) dmn.push_back({max(X[i], Y[i]), X[i], Y[i]}), dmx.push_back({min(X[i], Y[i]), X[i], Y[i]});
  sort(dmn.begin(), dmn.end());
  sort(dmx.begin(), dmx.end());
  reverse(dmx.begin(), dmx.end());
  int Q = S.size();
  vector<int> A(Q);
  for (int i=0; i<Q; i++)
  {
    for (int j=0; j<N; j++) dsu[j]=j;
    for (int j=0; j<dmx.size(); j++)
    {
      auto [w, u, v]=dmx[j];
      if (w<L[i]) break;
      dsu[find(u)]=find(v);
    }
    for (int j=0; j<dmn.size(); j++)
    {
      auto [w, u, v]=dmn[j];
      if (w>R[i]) break;
      dsu[find(u)]=find(v);
    }
    A[i]=find(S[i])==find(E[i]);
  }
  return A;
}

Compilation message

werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for (int i=0; i<X.size(); i++) dmn.push_back({max(X[i], Y[i]), X[i], Y[i]}), dmx.push_back({min(X[i], Y[i]), X[i], Y[i]});
      |                 ~^~~~~~~~~
werewolf.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int j=0; j<dmx.size(); j++)
      |                   ~^~~~~~~~~~~
werewolf.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int j=0; j<dmn.size(); j++)
      |                   ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 142 ms 40400 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -