QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#538917#8940. Piggy Sortucup-team1004#WA 1ms3740kbC++141.4kb2024-08-31 13:34:442024-08-31 13:34:44

Judging History

你现在查看的是最新测评结果

  • [2024-08-31 13:34:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3740kb
  • [2024-08-31 13:34:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include"debug.h"
#else
#define debug(...) void()
#endif
#define all(x) (x).begin(),(x).end()
template<class T>
auto ary(T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
using ll=long long;
using ull=unsigned long long;
const int N=5e2+10;
int T,n,m,a[N][N],cur[N],p[N],rk[N];
ll s[N];
bool find(int i,ll x){
	if(x>INT_MAX||x<INT_MIN)return 0;
	int k=lower_bound(a[i]+1,a[i]+1+n,x)-a[i];
	return k<=n&&a[i][k]==x;
}
bool chk(int i,int j){
	if(a[1][i]>a[2][j])return 0;
	for(int k=3;k<=m;k++){
		if((a[2][j]-a[1][i])*(s[k]-s[1])%(s[2]-s[1]))continue;
		ll pos=a[1][i]+(a[2][j]-a[1][i])*(s[k]-s[1])/(s[2]-s[1]);
		if(!find(k,pos))return 0;
	}
	return 1;
}
void get(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		s[i]=0;
		for(int j=1;j<=n;j++)cin>>a[i][j],s[i]+=a[i][j];
	}
	static int vis[N];
	fill(vis,vis+1+n,0);
	for(int i=n;i>=1;i--){
		p[i]=0;
		for(int j=1;j<=n&&!p[i];j++)if(!vis[j]){
			if(chk(i,j))p[i]=j,vis[j]=1;
		}
	}
	// debug(ary(p,1,n));
	iota(cur,cur+1+n,0);
	sort(cur+1,cur+1+n,[&](int x,int y){
		return make_pair(a[2][p[x]]-a[1][x],a[1][x])<make_pair(a[2][p[y]]-a[1][y],a[1][y]);
	});
	for(int i=1;i<=n;i++)rk[cur[i]]=i;
	for(int i=1;i<=n;i++)cout<<rk[i]<<"\n "[i<n];
}
int main(){
	for(cin>>T;T--;)get();
	return 0;
}
#ifdef DEBUG
#include"debug.hpp"
#endif

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

input:

3
2 4
1 2
3 4
5 6
7 8
1 2
1
1
3 4
1 2 3
6 9 9
10 15 17
12 18 21

output:

1 2
1
3 1 2

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3740kb

input:

41
1 2
-19
9531
2 3
11 13
3175 4759
2211 3313
10 19
-54 -25 -19 -18 -1 3 61 63 85 88
-54 753 863 2397 3111 4649 4671 4756 5507 7762
-54 369 479 1245 1575 2345 2367 2452 2819 3922
-54 553 663 1797 2311 3449 3471 3556 4107 5762
-54 87 197 399 447 653 675 760 845 1102
-54 320 430 1098 1379 2051 2073 21...

output:

1
2 1
1 10 9 8 7 6 5 4 3 2
9 8 7 6 5 1 4 3 2
1 3 8 10 7 2 9 6 4 5
10 9 8 7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
8 6 3 1 2 4 9 10 7 5
4 3 2 1
9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
1 10 9 8 7 6 5 4 3 2
10 8 6 9 5 7 4 3 2 1
9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
10 9 1 8 7 6 5 ...

result:

wrong answer 2nd lines differ - expected: '1 2', found: '2 1'