QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#85285#5689. 喵了个喵 IIfeecle6418TL 0ms0kbC++20843b2023-03-07 14:51:562023-03-07 14:53:05

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-07 14:53:05]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-03-07 14:51:56]
  • 提交

answer

#include<bits/stdc++.h>
const int N=200005;
using namespace std;

int n;
int a[N];

int cc[N];
int fl[N];
int A[N],cnt,nw;
void dfs(int k){
    if(1.*clock()/CLOCKS_PER_SEC>=3.8){
        cout<<"No"<<endl;
        exit(0);
    }
    if(k==n*4+1){
        cout<<"Yes"<<endl;
        for(int i=1;i<=n<<2;i++)
            cout<<fl[i];
        exit(0);
    }
    if(A[nw+1]==a[k]&&nw<cnt){
        nw++;
        dfs(k+1);
        nw--;
    }
    if(cnt==n*2)return ;
    if(cc[a[k]]==2)return ;
    cc[a[k]]++;
    fl[k]=1;
    A[++cnt]=a[k];
    dfs(k+1);
    cc[a[k]]--;
    cnt--;
    fl[k]=0;
}

void solve(){
    cin>>n;
    for(int i=1;i<=n*4;i++)
        cin>>a[i];
    dfs(1);
    cout<<"No"<<endl;
}

main(){
    ios::sync_with_stdio(0);
    int _T=1;//cin>>_T;
    while(_T--)solve();
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

50000
12725 41478 2443 1096 36968 36898 3393 45898 43154 26629 22985 37972 13935 25628 40196 40293 39791 29109 455 45812 12634 21086 8928 13600 25416 30244 15917 22568 35849 40189 27442 28785 46334 25651 7172 30994 39724 27853 47091 21306 42087 31612 22081 23002 17127 15269 11569 8254 41080 30112 31...

output:


result: