제출 #138795

#제출 시각아이디문제언어결과실행 시간메모리
138795Mahmoud_Adel곤돌라 (IOI14_gondola)C++14
컴파일 에러
0 ms0 KiB
#include "gondola.h" #include <bits/stdc++.h> #include "grader.cpp" using namespace std; typedef long long ll; const int N = 1e6+5, mod = 1e9+9; int mep[N]; map<ll, ll> mark; ll power(ll a, ll b) { if(!b) return 1; ll temp = power(a, b/2); temp = (temp*temp)%mod; if(b%2) temp *= a, temp %= mod; return temp; } int valid(int n, int inputSeq[]) { for(int i=0; i<n; i++) { if(mark[inputSeq[i]]) return 0; else mark[inputSeq[i]] = 1; } int j = -1; for(int i=0; i<n; i++) if(inputSeq[i] > 0 && inputSeq[i] <= n) j = i; if(j == -1) return 1; for(int i=0; i<n; i++) { int id = (i+j)%n, jd = (i+j+1)%n; if(inputSeq[jd] > n) inputSeq[jd] = inputSeq[id]%n + 1; if(inputSeq[jd] != inputSeq[id]%n + 1) return 0; } return 1; } //---------------------- int replacement(int n, int inputSeq[], int replacementSeq[]) { memset(mep, 0, sizeof mep); vector<int> vec; int j = -1; for(int i=0; i<n; i++) if(inputSeq[i] <= n) j = i; if(j == -1) for(int i=0; i<n; i++) vec.push_back(inputSeq[i]), mep[inputSeq[i]] = i+1; else { for(int i=0; i<n; i++) { int id = (i+j)%n, jd = (i+j+1)%n; if(inputSeq[jd] > n) { vec.push_back(inputSeq[jd]); mep[inputSeq[jd]] = inputSeq[id]%n + 1; inputSeq[jd] = inputSeq[id]%n + 1; } } } sort(vec.begin(), vec.end()); int cur = n+1, c = 0; for(int i : vec) { int last = mep[i]; while(cur < i) replacementSeq[c++] = last, last = cur, cur++; replacementSeq[c++] = last; } return c; } //---------------------- int countReplacement(int n, int inputSeq[]) { int tmp[n]; for(int i=0; i<n; i++) tmp[i] = inputSeq[i]; if(!valid(n, inputSeq)) return 0; for(int i=0; i<n; i++) inputSeq[i] = tmp[i]; ll j = -1, c = n; vector<ll> vec; for(int i=0; i<n; i++) if(inputSeq[i] <= n) j = i; else vec.push_back(inputSeq[i]); ll ans = 1; vec.push_back(n); sort(vec.begin(), vec.end()); for(int i=0; i<vec.size()-1; i++) { ll tmp = power((ll)vec.size()-i-1, vec[i+1]-vec[i]-1); ans = (ans%mod * tmp%mod)%mod; } return (ans*(j==-1? n:1))%mod; }

컴파일 시 표준 에러 (stderr) 메시지

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:85:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<vec.size()-1; i++)
               ~^~~~~~~~~~~~~
gondola.cpp:78:13: warning: unused variable 'c' [-Wunused-variable]
  ll j = -1, c = n;
             ^
/tmp/ccEZd8xH.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cch3taDr.o:gondola.cpp:(.text.startup+0x0): first defined here
/tmp/ccEZd8xH.o:(.bss+0xf4260): multiple definition of `gondolaSequence'
/tmp/cch3taDr.o:(.bss+0x4c4bc0): first defined here
/tmp/ccEZd8xH.o:(.bss+0x0): multiple definition of `replacementSequence'
/tmp/cch3taDr.o:(.bss+0x3d0960): first defined here
collect2: error: ld returned 1 exit status