Submission #311570

#TimeUsernameProblemLanguageResultExecution timeMemory
311570amunduzbaevMechanical Doll (IOI18_doll)C++14
Compilation error
0 ms0 KiB
#include "grader.cpp"
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector<pair<int,int > >s;
void create_circuit(int m, vector<int> a) {
    int n=a.size();
    vector<int> ans, way[N], x, y, c(m+1,0);
    way[0].push_back(a[0]);
    c[0]=a[0];
    for(int i=0;i<n-1;i++){
        if(way[a[i]].size()&&way[a[i]][0]!=a[i+1])
            ans.push_back(a[i]);
        way[a[i]].push_back(a[i+1]);
        c[a[i]]=a[i+1];
    }

    for(int i=0;i<ans.size();i++){
        int ind=i+1;
        c[ans[i]]=-ind;
    }
    answer(c,x,y);

}
/*

9 9
2 9 8 1 3 7 6 4 5

*/

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:9:26: error: reference to 'N' is ambiguous
    9 |     vector<int> ans, way[N], x, y, c(m+1,0);
      |                          ^
In file included from doll.cpp:1:
grader.cpp:25:8: note: candidates are: 'int {anonymous}::N'
   25 | int M, N;
      |        ^
doll.cpp:5:11: note:                 'const int N'
    5 | const int N=1e5+5;
      |           ^
doll.cpp:10:5: error: 'way' was not declared in this scope
   10 |     way[0].push_back(a[0]);
      |     ^~~
doll.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i=0;i<ans.size();i++){
      |                 ~^~~~~~~~~~~