Submission #284202

#TimeUsernameProblemLanguageResultExecution timeMemory
284202Bill_00Gondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include <stdlib.h> #include "gondola.h" #include <bits/stdc++.h> #define MOD 1e9+9; #define ll long long using namespace std; long long pow(long long a,int b){ if(b==1) return a; long long c=1; if(b%2==1) c=a; long long d=pow(a,b/2); return ((d*d)%MOD*c)%MOD; } int valid(int n, int a[]) { int k[250000]={0}; int y[250000]={0},d=0; for(int i=0;i<n;i++){ k[a[i]]++; } for(int i=0;i<n;i++){ if(k[a[i]]>1) return 0; } for(int i=0;i<n;i++){ if(a[i]<=n){ if(y[(a[i]-i+n)%n]==0) d++; y[(a[i]-i+n)%n]++; } } if(d<=1) return 1; return 0; } //---------------------- int replacement(int n, int a[], int replacementSeq[]) { int y[100000]={0}; for(int i=0;i<n;i++){ if(a[i]<=n){ y[(a[i]-i+n)%n]++; } } int e=0; for(int i=0;i<n;i++){ e=max(e,y[i]); } return n-e; } //---------------------- int countReplacement(int n, int a[]) { int e=0,k[250000]={0}; int y[250000]={0},d=0; vector<int>v; for(int i=0;i<n;i++){ k[a[i]]++; } v.push_back(n); for(int i=0;i<n;i++){ if(k[a[i]]>1) return 0; } for(int i=0;i<n;i++){ if(a[i]<=n){ e++; if(y[(a[i]-i+n)%n]==0) d++; y[(a[i]-i+n)%n]++; } else v.push_back(a[i]); } if(d>1) return 0; if(d==1 && e==n) return 1; sort(v.begin(),v.end()); int e=n-e; long long ans=1; for(int i=1;i<v.size();i++){ long long p=v[i]-v[i-1]-1; if(p==0) continue; ans=(ans*pow(p,e-i+1))%MOD; } return ans; }

Compilation message (stderr)

gondola.cpp: In function 'long long int pow(long long int, int)':
gondola.cpp:12:15: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   12 |  return ((d*d)%MOD*c)%MOD;
      |          ~~~~~^
      |            |
      |            long long int
gondola.cpp:4:18: error: expected ')' before ';' token
    4 | #define MOD 1e9+9;
      |                  ^
gondola.cpp:12:16: note: in expansion of macro 'MOD'
   12 |  return ((d*d)%MOD*c)%MOD;
      |                ^~~
gondola.cpp:12:9: note: to match this '('
   12 |  return ((d*d)%MOD*c)%MOD;
      |         ^
gondola.cpp:12:20: error: invalid type argument of unary '*' (have 'long long int')
   12 |  return ((d*d)%MOD*c)%MOD;
      |                    ^
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:77:6: error: redeclaration of 'int e'
   77 |  int e=n-e;
      |      ^
gondola.cpp:56:6: note: 'int e' previously declared here
   56 |  int e=0,k[250000]={0};
      |      ^
gondola.cpp:79:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |  for(int i=1;i<v.size();i++){
      |              ~^~~~~~~~~
gondola.cpp:82:25: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   82 |   ans=(ans*pow(p,e-i+1))%MOD;
      |       ~~~~~~~~~~~~~~~~~~^
      |           |
      |           long long int