QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#540276#8940. Piggy Sortucup-team4702#WA 1ms3928kbC++171.3kb2024-08-31 16:48:162024-08-31 16:48:17

Judging History

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

  • [2024-08-31 16:48:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3928kb
  • [2024-08-31 16:48:16]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
mt19937 g(time(0));
int calc(int x,int y,int z,int a,int b,int k){
  return z*b-y*a+(a-b)*k;
}
main(){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int t; cin>>t;
  while(t--){
    int n,m; cin>>n>>m;
    vector a(m,vector<int>(n));
    vector<int> c(m),c2(m),p(m);
    for(int i=0;i<m;i++)
      for(auto &j:a[i])cin>>j,c[i]+=j,c2[i]+=j*j;
    if(n==1){cout<<"1\n"; continue;}
    iota(p.begin(),p.end(),0);
    sort(p.begin(),p.end(),[&](int x,int y){
      return c[x]<c[y];
    });
    vector<int> v(n),r(n),p2(n);
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        for(int k=0;k<n;k++){
          int x=a[0][i],y=a[p[1]][j],z=a[p[2]][k],d=g()%(int)1e6+1;
          int c20=c2[0]-x*x,c21=c2[p[1]]-y*y,c22=c2[p[2]]-z*z;
          int nx=x+d,ny=y+d,nz=z+d;
          c20+=nx*nx,c21+=ny*ny,c22+=nz*nz;
          int aa=c[p[2]]-c[0],bb=c[p[1]]-c[0];
          if(calc(c20,c21,c22,aa,bb,nx*nx)==calc(c2[0],c2[p[1]],c2[p[2]],aa,bb,x*x))v[i]=y-x;
        }
    iota(r.begin(),r.end(),0);
    sort(r.begin(),r.end(),[&](int x,int y){
      return v[x]==v[y]?a[0][x]<a[0][y]:v[x]<v[y];
    });
    for(int i=0;i<n;i++)
      p2[r[i]]=i;
    for(int i:p2)cout<<i+1<<' ';
    cout<<'\n';
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 1ms
memory: 3720kb

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 6 10 5 7 9 4 3 8 
8 7 5 9 2 1 6 3 4 
1 6 5 9 8 2 3 10 4 7 
3 5 10 6 7 4 9 8 2 1 
4 3 1 8 2 5 6 7 
3 1 5 2 6 9 8 7 4 10 
2 3 1 4 
3 2 9 1 4 6 7 5 8 
1 5 2 6 7 3 4 8 9 
9 8 5 7 2 3 4 6 1 
1 2 4 8 5 7 10 6 9 3 
7 1 3 2 9 8 10 4 5 6 
7 8 1 2 5 6 3 9 4 
8 1 2 7 6 9 3 5 4 
8 1 2 4 5 10 9 3 6 7 ...

result:

ok 41 lines

Test #3:

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

input:

46
8 12
-50 -35 -20 -10 -9 4 13 91
-24 30 32 143 146 147 173 221
-44 -8 10 13 26 27 61 103
-46 -12 -3 8 14 15 45 99
-22 32 36 147 158 159 189 237
-47 -14 -11 7 8 9 37 97
-31 18 23 104 105 117 129 165
-45 -10 5 9 20 21 53 101
-36 8 18 74 75 77 119 125
-30 20 24 110 111 125 131 173
-48 -19 -16 2 3 6 2...

output:

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

result:

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