Submission #530171

#TimeUsernameProblemLanguageResultExecution timeMemory
530171gg123_peGondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "gondola.h" using namespace std; #define f(i,a,b) for(int i = a; i < b; i++) const int N = 250005; int cant[N], m[N]; bool on[N]; int valid(int n, int X[]){ f(i,0,n) cant[X[i]]++; int ct = 0, id; f(i,1,N) { if(cant[i] > 1) return 0; if(i <= n and cant[i]) ct++; } if(ct == 0) return 1; f(i,0,n) if(X[i] <= n) id = i; vector <int> a, v1, v2; int pr = X[id]-1; f(i,0,n-id){ pr++; if(pr == n+1) pr = 1; v2.push_back(pr); } f(i,0,id){ pr++; if(pr == n+1) pr = 1; v1.push_back(pr); } for(int x: v1) a.push_back(x); for(int x: v2) a.push_back(x); int ans = 1; f(i,0,n) if(X[i] <= n and a[i] != X[i]) ans = 0; return ans; } int replacement(int n, int X[], int &res[]){ int id = -1; f(i,0,n) if(X[i] <= n) id = i; vector <int> a, v1, v2; if(id != -1){ vector <int> a, v1, v2; int pr = X[id]-1; f(i,0,n-id){ pr++; if(pr == n+1) pr = 1; v2.push_back(pr); } f(i,0,id){ pr++; if(pr == n+1) pr = 1; v1.push_back(pr); } for(int x: v1) a.push_back(x); for(int x: v2) a.push_back(x); } else f(i,0,n) a.push_back(i+1); int maxi = 0; f(i,0,n) { if(X[i] > n) m[X[i]] = a[i], on[X[i]] = 1; maxi = max(maxi, X[i]); } vector <int> ans; id = n+1; while(id <= maxi){ int l = id; while(!on[id]) id++; ans.push_back(m[id]); f(i,l,id) ans.push_back(i); id++; } int l = ans.size(); f(i,0,l) res[i] = ans[i]; return l; } int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp:40:38: error: declaration of 'res' as array of references
   40 | int replacement(int n, int X[], int &res[]){
      |                                      ^~~
gondola.cpp: In function 'int replacement(...)':
gondola.cpp:42:11: error: 'n' was not declared in this scope
   42 |     f(i,0,n) if(X[i] <= n) id = i;
      |           ^
gondola.cpp:5:37: note: in definition of macro 'f'
    5 | #define f(i,a,b) for(int i = a; i < b; i++)
      |                                     ^
gondola.cpp:42:17: error: 'X' was not declared in this scope
   42 |     f(i,0,n) if(X[i] <= n) id = i;
      |                 ^
gondola.cpp:47:18: error: 'X' was not declared in this scope
   47 |         int pr = X[id]-1;
      |                  ^
gondola.cpp:48:15: error: 'n' was not declared in this scope
   48 |         f(i,0,n-id){
      |               ^
gondola.cpp:5:37: note: in definition of macro 'f'
    5 | #define f(i,a,b) for(int i = a; i < b; i++)
      |                                     ^
gondola.cpp:55:22: error: 'n' was not declared in this scope
   55 |             if(pr == n+1) pr = 1;
      |                      ^
gondola.cpp:61:16: error: 'n' was not declared in this scope
   61 |     else f(i,0,n) a.push_back(i+1);
      |                ^
gondola.cpp:5:37: note: in definition of macro 'f'
    5 | #define f(i,a,b) for(int i = a; i < b; i++)
      |                                     ^
gondola.cpp:64:11: error: 'n' was not declared in this scope
   64 |     f(i,0,n) {
      |           ^
gondola.cpp:5:37: note: in definition of macro 'f'
    5 | #define f(i,a,b) for(int i = a; i < b; i++)
      |                                     ^
gondola.cpp:65:12: error: 'X' was not declared in this scope
   65 |         if(X[i] > n) m[X[i]] = a[i], on[X[i]] = 1;
      |            ^
gondola.cpp:66:26: error: 'X' was not declared in this scope
   66 |         maxi = max(maxi, X[i]);
      |                          ^
gondola.cpp:69:10: error: 'n' was not declared in this scope
   69 |     id = n+1;
      |          ^
gondola.cpp:78:14: error: 'res' was not declared in this scope
   78 |     f(i,0,l) res[i] = ans[i];
      |              ^~~