제출 #308439

#제출 시각아이디문제언어결과실행 시간메모리
308439tengiz05Gondola (IOI14_gondola)C++17
55 / 100
32 ms4436 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; const int N = 1e5+5; int a[N]; int cnt[N*3]; int valid(int n, int inputSeq[]){ for(int i=0;i<n;i++)a[i] = inputSeq[i]; int i; for(i=0;i<n;i++)cnt[a[i]]++; for(i=0;i<N*3;i++)if(cnt[i] > 1)return 0; for(i=0;i<n;i++){ if(a[i] < n)break; }if(i == n)return 1; int now = a[i]; for(int j=0;j<n;j++){ if(a[i] <= n && a[i] != now)return 0; now++; if(now > n)now = 1; i++; i%=n; } return 1; } //---------------------- bool Fixed[N]; int b[N]; int expect[N*3]; int replacement(int n, int gondolaSeq[], int replacementSeq[]){ set<int> not_fixed; for(int i=0;i<N*3;i++)expect[i] = -1; for(int i=0;i<n;i++)a[i] = gondolaSeq[i]; int idx = n; for(int i=0;i<n;i++){ if(a[i] <= n){idx = i; break;} }if(idx != n){ int now = a[idx]; for(int j=0;j<n;j++){ b[idx] = now; idx++; idx %= n; now++; if(now == n+1)now = 1; } }else { for(int i=0;i<n;i++)b[i] = i+1; } for(int i=0;i<n;i++){ if(a[i] <= n)Fixed[i] = true; else { not_fixed.insert(i); expect[a[i]] = i; } } vector<int> ans; int now = n+1; while(not_fixed.size() > 0){ if(expect[now] == -1){ ans.push_back(b[*not_fixed.begin()]); b[*not_fixed.begin()] = now; }else { ans.push_back(b[expect[now]]); b[expect[now]] = n; not_fixed.erase(expect[now]); }now++; } for(int i=0;i<ans.size();i++){ replacementSeq[i] = ans[i]; } return (int)ans.size(); } /* 4 7 2 3 4 9 6 7 1 */ //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

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

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:69:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |  for(int i=0;i<ans.size();i++){
      |              ~^~~~~~~~~~~
#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...