QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#879710#8940. Piggy SortfryanWA 0ms3712kbC++201.6kb2025-02-02 11:27:502025-02-02 11:27:50

Judging History

This is the latest submission verdict.

  • [2025-02-02 11:27:50]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3712kb
  • [2025-02-02 11:27:50]
  • Submitted

answer

#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
#define int long long

const int mxn = 505;

int n,m;
vector<vector<int>> x;
vector<int> su;
vector<pair<long double,int>> pt;
int pos[mxn];

void solve() {
	cin>>n>>m; x.resize(m); su.resize(m);
	for (int i=0; i<m; i++) {
		x[i].resize(n);
		su[i] = 0;
		for (int j=0; j<n; j++) {
			cin>>x[i][j];
			su[i] += x[i][j];
		}
		sort(all(x[i]));
	}
		
	for (int i=0; i<n; i++) {
		int cx = x[0][0];
		int cy = su[0];
			
		int te = -69420;
		
		for (int nx : x[1]) {
			int ny = su[1];
			int ok=1;
//			cout<<cx<<" "<<cy<<"  "<<nx<<" "<<ny<<endl;
			for (int j=2; j<m; j++) {
				int y = su[j];
				int vv = (nx-cx)*(y-cy);
//				cout<<vv<<endl;
				if (vv%(ny-cy)==0) {
					vv/=(ny-cy);
					vv+=cx;
				} else {
					ok = 0;
					break;
				}
				if (binary_search(all(x[j]),vv)) {
					continue;
				} else {
					ok = 0;
				}
			}
			if (ok) {
				x[0].erase(find(all(x[0]),cx));
				te = nx;
				
				for (int j=2; j<m; j++) {
					int y = su[j];
					int vv = (nx-cx)*(y-cy)/(ny-cy);
					x[j].erase(lower_bound(all(x[j]),vv));
				}
				
				pt.push_back({(nx-cx)/1.0/(ny-cy),i});
				break;
			}
		}
	//	cout<<cx<<endl;
	//	cout<<te<<endl;
		x[1].erase(find(all(x[1]),te));
	}
	sort(all(pt));
	for (int i=0; i<sz(pt); i++) {
		pos[pt[i].second] = i+1;
	}
	pt.clear();
	for (int i=0; i<n; i++) {
		cout<<pos[i]<<" ";
	}
	cout<<"\n";
	
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int t; cin>>t;
	while (t--) {
		solve();
	}
}

詳細信息

Test #1:

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

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: 0ms
memory: 3712kb

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 
1 2 
1 2 0 0 0 0 0 0 0 0 
3 2 1 0 0 0 0 0 0 
1 2 1 0 0 0 0 0 0 0 
1 2 1 0 0 0 0 0 0 0 
3 2 1 4 0 0 0 0 
2 1 1 4 0 0 0 0 0 0 
2 3 1 4 
3 2 4 1 0 0 0 0 0 
1 2 4 1 0 0 0 0 0 
5 4 2 3 1 0 0 0 0 
1 4 2 3 1 0 0 0 0 0 
2 1 2 3 1 0 0 0 0 0 
1 1 2 3 1 0 0 0 0 
4 1 2 3 1 0 0 0 0 
2 1 2 3 1 0 0 0 0 0 
3 2 1...

result:

wrong answer 3rd lines differ - expected: '1 2 6 10 5 7 9 4 3 8', found: '1 2 0 0 0 0 0 0 0 0 '