Submission #253863

#TimeUsernameProblemLanguageResultExecution timeMemory
253863ChrisTGondola (IOI14_gondola)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #include "gondola.h" int valid (int n, int *a) { set<int> seen; for (int i = 0; i < n; i++) { if (seen.count(a[i])) return 0; seen.insert(a[i]); } for (int i = 0; i < n; i++) { if (a[i] <= n) { for (int j = (i+1)%n, cur = a[i]%n+1; j != i; j = (j + 1) % n, cur = cur % n + 1) { if (a[j] <= n && a[j] != cur) return 0; } return 1; } } return 1; } int replacement (int n, int *a, int *ret) { vector<int> pos(250001,-1), cur(n); int mx = 0; for (int i = 0; i < n; i++) if (a[i] <= n) { cur[i] = a[i]; for (int j = (i+1)%n, go = a[i]%n+1; j != i; j = (j + 1) % n, go = go % n + 1) cur[j] = go; break; } if (!cur[0]) for (int i = 0; i < n; i++) cur[i] = i+1; for (int i = 0; i < n; i++) { pos[a[i]] = i; if (a[i] > a[mx]) mx = i; } int pp = 0; for (int i = n+1; i <= a[mx]; i++) { if (~pos[i]) ret[pp++] = cur[pos[i]], cur[pos[i]] = i; else ret[pp++] = cur[mx], cur[mx] = i; } return pp; } int fpow (int base, int exp) { int res = 1; while (exp) { if (exp&1) res = 1LL * res * base % MOD; base = 1LL * base * base % MOD; exp >>= 1; } return res; } int countReplacement (int n, int *a) { if (!valid(n,a)) return 0; sort(a,a+n); int lst = n, ret = 1; for (int i = 0; i < n; i++) if (a[i] > n) { ret = ret * 1LL * fpow(n-i,a[i]-lst-1) % MOD; lst = a[i]; } if(a[0]>n)ret=ret*1LL*n%MOD; return ret; }

Compilation message (stderr)

gondola.cpp: In function 'int fpow(int, int)':
gondola.cpp:42:39: error: 'MOD' was not declared in this scope
   if (exp&1) res = 1LL * res * base % MOD;
                                       ^~~
gondola.cpp:43:30: error: 'MOD' was not declared in this scope
   base = 1LL * base * base % MOD;
                              ^~~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:53:44: error: 'MOD' was not declared in this scope
   ret = ret * 1LL * fpow(n-i,a[i]-lst-1) % MOD;
                                            ^~~
gondola.cpp:56:26: error: 'MOD' was not declared in this scope
  if(a[0]>n)ret=ret*1LL*n%MOD;
                          ^~~