QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#378618#8566. Can We Still Qualify For Semifinals?ucup_team_qiuly#TL 0ms0kbC++141.3kb2024-04-06 13:46:582024-04-06 13:46:58

Judging History

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

  • [2024-04-06 13:46:58]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-04-06 13:46:58]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int a[15];
int tot,qwq[50][2];
int val[15];
int fg;
bool check(){
    int cnt=0;
    for (int i=1;i<10;i++)
        if (val[i]>val[0])cnt++;
    if (cnt>3)return 0;
    return 1;
}
void dfs(int x){
    if (x==45){
        if (check())fg=1;
        return;
    }
    if (qwq[x][0]==0||qwq[x][1]==0)dfs(x+1);
    else val[qwq[x][0]]++,dfs(x+1),val[qwq[x][0]]--,val[qwq[x][1]]++,dfs(x+1),val[qwq[x][1]]--;
    return;
}
int main(){
    for (int i=1;i<=10;i++)a[i]=i;
    for (int i=1;i<=9;i++){
        for (int l=1,r=10;l<r;l++,r--)qwq[tot][0]=a[l]-1,qwq[tot][1]=a[r]-1,tot++;
        int v=a[10];
        for (int j=10;j>=3;j--)a[j]=a[j-1];
        a[2]=v;
    }
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        string str;
        cin>>str;
        memset(val,0,sizeof(val));
        for (int i=0;i<n;i++){
            if (str[i]=='1')val[qwq[i][0]]++;
            else val[qwq[i][1]]++;
        }
        for (int i=n;i<45;i++)
            if (val[i]==0)
        if (n<=15){
            puts("YES");
            continue;
        }
        fg=0;
        dfs(n);
        if (fg==1)puts("YES");
        else puts("NO");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3
3
111
25
1000010101111111111010100
35
01111011110111101111011110111101111

output:


result: