제출 #428389

#제출 시각아이디문제언어결과실행 시간메모리
428389Amylopectin곤돌라 (IOI14_gondola)C++14
90 / 100
31 ms2372 KiB
#include <iostream> #include <stdio.h> #include <algorithm> #include "gondola.h" //#include "grader.cpp" using namespace std; const long long mxn = 4e5 + 10,mo = 1e9 + 9; struct we { long long stn,thn; }; bool cmp(const struct we &l,const struct we &r) { return l.thn < r.thn; } struct we so[mxn] = {}; int u[mxn] = {}; int valid(int n, int inp[]) { long long i,j,m,stp = -1,of = 0; for(i=0; i<n; i++) { if(stp == -1 && inp[i] <= n) { stp = i - inp[i] + 1; if(stp < 0) { stp += n; } } if(stp >= 0 && inp[i] <= n) { if((stp + inp[i] - 1) % n != i) { of = 1; break; } } } for(i=0; i<n; i++) { if(u[inp[i]] == 1) { of = 1; break; } else { u[inp[i]] = 1; } } if(of == 0) { return 1; } return 0; } int replacement(int n, int inp[], int ans[]) { long long i,j,ru = 0,stp = -1,fr,ba,rua = 0; for(i=0; i<n; i++) { if(stp == -1 && inp[i] <= n) { stp = i - inp[i] + 1; if(stp < 0) { stp += n; } break; } } if(stp == -1) { stp = 0; } for(i=0; i<n; i++) { if(inp[i] > n) { so[ru] = {(i + n - stp) % n + 1,inp[i]}; ru ++; } } sort(so,so+ru,cmp); fr = 0; ba = 0; // while(ba < ru) // { // } for(i=n+1; i<=so[ru-1].thn; i++) { if(i == so[fr].thn) { ans[rua] = so[fr].stn; rua ++; fr ++; // if(ba < fr) // { // ba = fr; // } } else { ans[rua] = so[fr].stn; so[fr].stn = i; rua ++; } } return rua; } int countReplacement(int n, int inp[]) { long long i,j,m,stp = -1,of = 0,ans = 1,be,ru = 0,off = 0; for(i=0; i<n; i++) { if(stp == -1 && inp[i] <= n) { stp = i - inp[i] + 1; if(stp < 0) { stp += n; } } if(stp >= 0 && inp[i] <= n) { if((stp + inp[i] - 1) % n != i) { of = 1; break; } } } for(i=0; i<n; i++) { if(u[inp[i]] == 1) { of = 1; break; } else { u[inp[i]] = 1; } } if(of == 1) { return 0; } if(stp == -1) { off = 1; ans *= n; stp = 0; } for(i=0; i<n; i++) { if(inp[i] > n) { so[ru] = {(i + n - stp) % n + 1,inp[i]}; ru ++; } } sort(so,so+ru,cmp); be = n; for(i=0; i<ru; i++) { for(j=be+1; j<so[i].thn; j++) { ans *= ru-i; ans %= mo; } be = so[i].thn; } return ans; // return -3; } //int main() //{ // // return 0; //}

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

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:20:17: warning: unused variable 'j' [-Wunused-variable]
   20 |     long long i,j,m,stp = -1,of = 0;
      |                 ^
gondola.cpp:20:19: warning: unused variable 'm' [-Wunused-variable]
   20 |     long long i,j,m,stp = -1,of = 0;
      |                   ^
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:60:17: warning: unused variable 'j' [-Wunused-variable]
   60 |     long long i,j,ru = 0,stp = -1,fr,ba,rua = 0;
      |                 ^
gondola.cpp:60:38: warning: variable 'ba' set but not used [-Wunused-but-set-variable]
   60 |     long long i,j,ru = 0,stp = -1,fr,ba,rua = 0;
      |                                      ^~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:114:19: warning: unused variable 'm' [-Wunused-variable]
  114 |     long long i,j,m,stp = -1,of = 0,ans = 1,be,ru = 0,off = 0;
      |                   ^
gondola.cpp:114:55: warning: variable 'off' set but not used [-Wunused-but-set-variable]
  114 |     long long i,j,m,stp = -1,of = 0,ans = 1,be,ru = 0,off = 0;
      |                                                       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...