이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll MOD=1e9+9;
ll pot(ll a, ll b) {
ll ans=1;
while(b) {
if(b&1) ans=(ans*a)%MOD;
a=(a*a)%MOD;
b/=2;
}
return ans;
}
int valid(int n, int T[]) {
rep(i, n) --T[i];
map<int,int>mp;
rep(i, n) {
++mp[T[i]];
if(mp[T[i]]>1) return 0;
}
rep(i, n) if(T[i]<n) {
rep(j, n) if(T[(i+j)%n]<n) {
if(T[(i+j)%n]!=(T[i]+j)%n) return 0;
}
return 1;
}
return 1;
}
int replacement(int n, int T[], int ans[]) {
rep(i, n) if(T[i]<=n) {
int P[n];
rep(j, n) P[(j+T[i]-1-i+n)%n]=T[j];
rep(j, n) T[j]=P[j];
break;
}
int ma=0;
rep(i, n) ma=max(ma, T[i]);
rep(i, n) if(T[i]>n && T[i]!=ma) ans[T[i]-n-1]=i+1;
rep(i, n) if(T[i]==ma) {
int lst=i+1;
rep(j, ma-n) if(!ans[j]) {
ans[j]=lst;
lst=j+n+1;
}
}
return ma-n;
}
int countReplacement(int n, int T[]) {
if(!valid(n, T)) return 0;
vector<ll>V;
V.pb(0);
rep(i, n) if(T[i]>=n) V.pb(T[i]-n+1);
sort(all(V));
ll ans=1;
for(ll i=1; i<V.size(); ++i) ans=(ans*pot(V.size()-i, V[i]-V[i-1]-1))%MOD;
int p=0;
rep(i, n) if(T[i]>=n) ++p;
if(p==n) ans=(ans*n)%MOD;
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:62:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | for(ll i=1; i<V.size(); ++i) ans=(ans*pot(V.size()-i, V[i]-V[i-1]-1))%MOD;
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |