이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<gondola.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 998244353;
int n;
int nxt(int lol, int n){
if(lol<n-1) return lol+1;
else return 0;
}
int nxtg(int lol, int n){
if(lol==n) return 1;
else return (lol+1);
}
int valid(int n, int v[]){
int cnt[250001];
memset(cnt, 0, sizeof cnt);
int mn=250001, mx=0, br=0, idx;
for(int i=0; i<n; i++){
if(mn>v[i]){
mn=v[i];
idx=i;
}
mx=max(mx, v[i]);
}
int xd=idx;
if(v[xd]<=n && v[xd]!=mn+((xd-idx+n)%n)) return 0;
cnt[v[xd]]++;
xd=nxt(xd, n);
while(xd!=idx){
if(v[xd]<=n && v[xd]!=mn+((xd-idx+n)%n)) return 0;
cnt[v[xd]]++;
xd=nxt(xd, n);
}
for(int i=1; i<=n; i++){
if(cnt[i]>1) return 0;
}
for(int i=n+1; i<=mx; i++){
if(cnt[i]!=1) return 0;
}
return 1;
}
int replacement(int n, int v[], int s[]){
int mn=250001, mx=0, idx;
int cnt[250001];
memset(cnt, 0, sizeof cnt);
for(int i=0; i<n; i++){
cnt[v[i]]++;
if(mn>v[i]){
mn=v[i];
idx=i;
}
mx=max(mx, v[i]);
}
cnt[n]=1;
idx=(idx-(mn-1)+n)%n;
int xd=idx;
if(v[xd]>n){
s[v[xd]-(n+1)]=1+((xd-idx+n)%n);
}
xd=nxt(xd, n);
while(xd!=idx){
if(v[xd]>n){
//cout<<v[xd]-n-1<<" "<<1+((xd-idx+n)%n)<<"\n";
int lst=v[xd];
while(cnt[lst-1]==0) lst--;
s[lst-(n+1)]=1+((xd-idx+n)%n);
while(cnt[lst]==0){
lst++;
s[lst-(n+1)]=lst-1;
}
///if(xd>=idx) s[v[xd]-(n+1)]=1+(xd-idx);
///else s[v[xd]-(n+1)]=1+(n-idx)+1+(xd);
}
xd=nxt(xd, n);
}
//cout<<mx-n<<endl;
//for(int i=0; i<(mx-n); i++) cout<<s[i]<<" ";
return mx-n;
}
int countReplacement( int n, int num[] ) {return 0;}
컴파일 시 표준 에러 (stderr) 메시지
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:30:26: warning: unused variable 'br' [-Wunused-variable]
int mn=250001, mx=0, br=0, idx;
^~
gondola.cpp:42:13: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
while(xd!=idx){
~~^~~~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:69:13: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
idx=(idx-(mn-1)+n)%n;
~~~^~~~~~~
# | 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... |