제출 #579123

#제출 시각아이디문제언어결과실행 시간메모리
579123MohamedFaresNebiliGondola (IOI14_gondola)C++14
100 / 100
24 ms2384 KiB
#include <bits/stdc++.h> #include "gondola.h" #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; using ll = long long; using ii = pair<int, int>; #define pb push_back #define pp pop_back #define ff first #define ss second typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; const int MOD = 1e9 + 9; bitset<1000000001> vis; int valid(int n, int arr[]) { for(int l = 0; l < n; l++) { if(vis[arr[l]]) return 0; vis[arr[l]] = 1; } int P = -1; for(int l = 0; l < n; l++) { if(arr[l] > n) continue; int K = arr[l] - l + n * 2; K %= n; if(P == -1) P = K; if(K != P) return 0; } return 1; } //---------------------- int replacement(int n, int arr[], int replacementSeq[]) { ii A[n]; int l = 0; while(l < n && arr[l] > n) l++; if(l == n) { for(l = 0; l < n; l++) A[l] = {arr[l], l + 1}; } else { int V = arr[l]; for(int i = 0; i < n; l = (l + 1) % n, i++) { A[l] = {arr[l], V}; V = (V % n) + 1; } } sort(A, A + n); int curr = n + 1; int res = 0; for(auto E : A) { int U = E.ff, V = E.ss; while(U != V) { replacementSeq[res++] = V; V = curr; curr++; } } return res; } //---------------------- ll pw(ll A, ll B) { if(B == 0) return 1ll; ll res = pw(A, B / 2); res = (res * res) % MOD; if(B & 1) res = (res * A) % MOD; return res; } int countReplacement(int n, int inputSeq[]) { if(!valid(n, inputSeq)) return 0; vector<int> arr; for(int l = 0; l < n; l++) { if(inputSeq[l] <= n) continue; arr.pb(inputSeq[l]); } sort(arr.begin(), arr.end()); ll res = 1, p = n; for(int l = 0; l < arr.size(); l++) { res = (res * pw(ll(arr.size() - l), ll(arr[l] - p - 1))) % MOD; p = arr[l]; } return (res * ll(arr.size() == n ? n : 1)) % MOD; }

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

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:83:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |             for(int l = 0; l < arr.size(); l++) {
      |                            ~~^~~~~~~~~~~~
gondola.cpp:87:41: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   87 |             return (res * ll(arr.size() == n ? n : 1)) % MOD;
      |                              ~~~~~~~~~~~^~~~
#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...