QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#32213#2571. Aidana and PitaRobeZH#WA 1880ms3732kbC++1.3kb2022-05-18 05:17:022022-05-18 05:17:03

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-18 05:17:03]
  • 评测
  • 测评结果:WA
  • 用时:1880ms
  • 内存:3732kb
  • [2022-05-18 05:17:02]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define st first
#define nd second
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
const int N=30;
int a[N],n,cpy[N];
int ot[N],s[N],now[N];
mt19937 rng(19260817);
int tmp[4],ans;
int it = 0;
bool should_stop() {
    return (++it) % 10000 == 0 && (double)clock() / CLOCKS_PER_SEC > 1.9;
}
int main() {
    scanf("%d",&n);
    //n=20;
    ans=1;
    rep(i,n){
        scanf("%d",a+i);
        //a[i]=i*i;
        cpy[i]=a[i];ans+=a[i];
    }
    while(true){
        if(should_stop()) break;
        shuffle(a+1,a+n+1,rng);
        tmp[1]=tmp[2]=tmp[3]=0;
        rep(i,n){
            rep(j,3)if(tmp[j]<=tmp[j%3+1]&&tmp[j]<=tmp[(j%3+1)%3+1]){
                    tmp[j]+=a[i];
                    now[i]=j;
                    break;
                }
        }
        int ret=0;
        rep(i,3)ret=max(ret,abs(tmp[i]-tmp[i%3+1]));
        if(ret<ans){
            ans=ret;
            rep(i,n)s[i]=now[i];
        }
    }
    rep(i,n){
        rep(j,n)if(cpy[j]==a[i]){
                cpy[j]=0;
                ot[j]=s[i];
                break;
            }
    }
    //printf("%d\n",ans);
    rep(i,n)printf("%d%c",ot[i]," \n"[i==n]);
    return 0;
}
/*
20
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1880ms
memory: 3732kb

input:

5
2 3 1 4 2

output:

1 1 2 3 3

result:

wrong answer expected 0, found 5