답안 #1073801

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073801 2024-08-24T21:45:42 Z Gabriel 통행료 (IOI18_highway) C++17
12 / 100
164 ms 20304 KB
#include "highway.h"
#include "bits/stdc++.h"
using namespace std;
void find_pair(int N, vector<int> U, vector<int> V, int A, int B){
  int n = N;
  int m = U.size();
  vector<int> a(m, 0);
  int d = (int)(ask(a) / (long long)A);
  set<int> Posibles;
  vector<int> Padres(n, -1);
  Padres[0] = 0;
  vector<bool> Visitados(n, 0);
  Visitados[0] = 1;
  deque<int> Cola;
  vector< vector<int> > Grafo(n);
  map< pair<int, int>, int> Identificador;
  for(int i = 0; i < m; i++){
    Grafo[U[i]].push_back(V[i]);
    Grafo[V[i]].push_back(U[i]);
    Identificador[make_pair(U[i], V[i])] = i;
    Identificador[make_pair(V[i], U[i])] = i;
  }
  Cola.push_back(0);
  vector<int> Distancia(n, INT_MAX);
  Distancia[0] = 0;
  while(!Cola.empty()){
    int Nodo = Cola[0];
    Cola.pop_front();
    Visitados[Nodo] = 1;
    for(auto E: Grafo[Nodo]){
      if(!Visitados[E]){
        Cola.push_back(E);
        Padres[E] = Nodo;
        Distancia[E] = Distancia[Nodo] + 1;
        if(Distancia[E] == d) Posibles.insert(E);
      }
    }
  }
  while(Posibles.size() > 1){
    vector<int> Pregunta(m, 0);
    int i = 0;
    for(auto E: Posibles){
      if(i % 2 == 0){
        Pregunta[Identificador[make_pair(E, Padres[E])]] = 1;
      }
      i++;
    }
    long long D = (long long)d * (long long)A;
    long long DD = ask(Pregunta);
    set<int> Nuevo;
    if(D == DD){
      int i = 0;
      for(auto E: Posibles){
        if(i % 2 == 1){
          Nuevo.insert(E);
        }
        i++;
      }
    } else {
      int i = 0;
      for(auto E: Posibles){
        if(i % 2 == 0){
          Nuevo.insert(E);
        }
        i++;
      }
    }
    Posibles = Nuevo;
  }
  answer(0, *Posibles.begin());
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 380 KB Output is correct
12 Correct 0 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 12 ms 2556 KB Output is correct
3 Correct 164 ms 20064 KB Output is correct
4 Correct 142 ms 20064 KB Output is correct
5 Correct 157 ms 20088 KB Output is correct
6 Correct 150 ms 19732 KB Output is correct
7 Correct 156 ms 19796 KB Output is correct
8 Correct 158 ms 20304 KB Output is correct
9 Correct 142 ms 19692 KB Output is correct
10 Correct 156 ms 20072 KB Output is correct
11 Correct 142 ms 19440 KB Output is correct
12 Correct 136 ms 19436 KB Output is correct
13 Correct 135 ms 19316 KB Output is correct
14 Correct 132 ms 19468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 2392 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 2648 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 2648 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -