Submission #786825

#TimeUsernameProblemLanguageResultExecution timeMemory
786825BoasStray Cat (JOI20_stray)C++17
15 / 100
1615 ms16540 KiB
#include "Anthony.h"
#include <bits/stdc++.h>

namespace
{

}

using namespace std;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;

int a, m;

vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V)
{
  a = A;
  m = M;
  vector<int> X(M, -1);
  queue<pair<int, int>> q;
  q.push({0, A - 1});
  while (!q.empty())
  {
    auto &[i, mark] = q.front();
    q.pop();
    for (int j = 0; j < m; j++)
    {
      if (X[j] != -1)
        continue;
      if (U[j] == i)
      {
        cerr << "Road from " << U[j] << " to " << V[j] << " gets mark " << mark << endl;
        X[j] = mark;
        q.push({V[j], (mark - 1 + a) % a});
      }
      else if (V[j] == i)
      {
        cerr << "Road from " << U[j] << " to " << V[j] << " gets mark " << mark << endl;
        X[j] = mark;
        q.push({U[j], (mark - 1 + a) % a});
      }
    }
  }
  return X;
}
#include "Catherine.h"
#include <vector>
#include <map>
#include <iostream>

namespace
{

  int A, B;

} // namespace

void Init(int A, int B)
{
  ::A = A;
  ::B = B;
}
using namespace std;
int Move(std::vector<int> y)
{
  vector<int> leastOccurences = {};
  int least = (1 << 30);
  map<int, int> occurences;
  for (int j = 0; j < A; ++j)
  {
    if (y[j] > 0)
    {
      if (y[j] < least)
      {
        least = y[j];
        leastOccurences = {j};
      }
      else if (y[j] == least)
      {
        leastOccurences.push_back(j);
      }
      occurences[j] = y[j];
    }
  }
  if (A > 2)
  {
    if (occurences.find(A - 1) != occurences.end() && occurences.find(0) != occurences.end())
    {
      return 0;
    }
    int max = 0;
    for (const auto &[j, c] : occurences)
    {
      max = std::max(j, max);
    }
    return max;
  }

  if (leastOccurences.size() == 0)
  {
    throw;
    return -1;
  }

  if (leastOccurences.size() == 1)
    return leastOccurences[0];
  // extra code for long straight lines with A = 2
  return -2;
}
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...