Submission #1199245

#TimeUsernameProblemLanguageResultExecution timeMemory
1199245repsakMechanical Doll (IOI18_doll)C++20
2 / 100
62 ms9288 KiB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

void create_circuit(int M, std::vector<int> A) {
  int N = A.size();
  
  vector<int> C(M + 1);
  vector<int> X(N); vector<int>Y(N);

  int prevC = 0;
  map<int, int> times;

  int counter = 0;

  for(int i = 0; i < N; i++){
    int valueToGoTo = A[i];
    times[valueToGoTo]++;

    if(times[valueToGoTo] == 2){
      X[counter] = C[valueToGoTo];
      Y[counter] = valueToGoTo;
      counter++;
      
      C[valueToGoTo] = -counter;
      prevC = valueToGoTo;

    }else{
      C[prevC] = A[i];
      prevC = C[prevC];
    }
  }

  answer(C, X, Y);
}
#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...