Submission #115400

#TimeUsernameProblemLanguageResultExecution timeMemory
115400dsjongMechanical Doll (IOI18_doll)C++14
6 / 100
94 ms15140 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; bool vis[100005]; int cnt[100005]; vector<int>adj[100005]; void create_circuit(int M, vector<int> A){ vector<int>C(M+1); memset(vis,false,sizeof vis); A.push_back(0); int S=0; C[0]=A[0]; for(int i=0;i<A.size()-1;i++){ cnt[A[i]]++; adj[A[i]].push_back(A[i+1]); if(cnt[A[i]]==2) S++; } vector<int>X(S),Y(S); int cur=-1; for(int i=0;i<A.size()-1;i++){ if(vis[A[i]]){ Y[-cur-1]=A[i+1]; X[-cur-1]=adj[A[i]][0]; C[A[i]]=cur--; } else C[A[i]]=A[i+1]; vis[A[i]]=true; } for(int i=1;i<=M;i++){ if(cnt[i]==0) C[i]=1; } /*cout<<C.size()<<endl; for(int i:C) cout<<i<<" "; cout<<endl; cout<<X.size()<<endl; for(int i:X) cout<<i<<" "; cout<<endl; cout<<Y.size()<<endl; for(int i:Y) cout<<i<<" "; cout<<endl;*/ answer(C,X,Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i=0;i<A.size()-1;i++){
      |              ~^~~~~~~~~~~
doll.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(int i=0;i<A.size()-1;i++){
      |              ~^~~~~~~~~~~
#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...