Submission #999335

# Submission time Handle Problem Language Result Execution time Memory
999335 2024-06-15T10:13:32 Z MarwenElarbi Mechanical Doll (IOI18_doll) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
const int nax=2e5+5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<int> adj[nax];
int vis[nax];
int counter=0;
void create_circuit(int M, std::vector<int> A) {
  vector<int> X,Y;
  vector<int> C(M+1);
  C[0]=A[0];
  int N = A.size();
  A.pb(0);
  for (int i = 0; i < N; ++i)
  {
    adj[A[i]].pb(A[i+1]);
  }
  for (int i = 0; i < N; ++i)
  {
    if(vis[A[i]]>0) continue;
    vis[A[i]]=1;
    if(adj[A[i]].size()==1){
      C[A[i]]=A[i+1];
      continue;
    }
    X.emplace_back();
    Y.emplace_back();
    C[A[i]]=-(int)(X.size());
    for (int j = 0; j < adj[A[i]].size()-2; ++j)
    {
      cout <<A[i]<<" "<<j<<endl;
      X.back()=adj[A[i]][j];
      Y.back()=-((int)X.size()+1);
      X.emplace_back();
      Y.emplace_back();
    }
    X.back()=adj[A[i]][adj[A[i]].size()-2];
    Y.back()=adj[A[i]][adj[A[i]].size()-1];
  }
  /*for (int i = 0; i < M+1; ++i)
  {
    cout << C[i]<<" ";
  }cout <<endl;
  for (int i = 0; i < X.size(); ++i)
  {
    cout <<X[i]<<" ";
  }cout <<endl;
  for (int i = 0; i < Y.size(); ++i)
  {
    cout <<Y[i]<<" ";
  }cout <<endl;*/
  answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int j = 0; j < adj[A[i]].size()-2; ++j)
      |                     ~~^~~~~~~~~~~~~~~~~~~~
doll.cpp:58:3: error: 'answer' was not declared in this scope
   58 |   answer(C, X, Y);
      |   ^~~~~~