이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<cstdio>
#include<algorithm>
using namespace std;
int gi(){
int x=0,w=1;char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
if(ch=='-')w=0,ch=getchar();
while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return w?x:-x;
}
#define ll long long
#define pi pair<ll,ll>
#define mk make_pair
#define fi first
#define se second
const int N=2005;
pi p[N][N],ans1[N];int n,m,val[N],vis[N],ans2[N];
bool cmp(pi a,pi b){return (long double)a.fi/a.se<(long double)b.fi/b.se;}
int main(){
n=gi();m=gi();
for(int i=1;i<=n;++i){
ll sum=0,now=0;
for(int j=1;j<=m;++j)sum+=(val[j]=gi());
for(int j=1,k=1;j<=n;++j){
while(k<m&&(now+val[k])*n<sum*j)now+=val[k++];
ll a=1ll*n*val[k]*(k-1)+sum*j-now*n,b=1ll*n*val[k],d=__gcd(a,b);
p[i][j]=mk(a/d,b/d);
}
}
for(int i=1;i<=n;++i){
int x=0;p[x][i]=mk(1,0);
for(int j=1;j<=n;++j)if(!vis[j])x=cmp(p[j][i],p[x][i])?j:x;
ans1[i]=p[x][i];ans2[i]=x;vis[x]=1;
}
for(int i=1;i<n;++i)printf("%lld %lld\n",ans1[i].fi,ans1[i].se);
for(int i=1;i<=n;++i)printf("%d ",ans2[i]);return puts(""),0;
}
컴파일 시 표준 에러 (stderr) 메시지
naan.cpp: In function 'int main()':
naan.cpp:36:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
36 | for(int i=1;i<=n;++i)printf("%d ",ans2[i]);return puts(""),0;
| ^~~
naan.cpp:36:48: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
36 | for(int i=1;i<=n;++i)printf("%d ",ans2[i]);return puts(""),0;
| ^~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |