Submission #67722189
Source Code Expand
#include <bits/stdc++.h>
#define _F(x,y,z) for(int x=y;x<=z;x++)
#define F_(x,z,y) for(int x=z;x>=y;x--)
#define TF(x,y,z) for(int x=head[y],z;x;x=nex[x])
#define GF(x,y,z) for(int x:z[y])
using namespace std;
typedef long long ll;
typedef double dou;
typedef const int ci;
typedef pair<int,int> pii;
ci maxn=2e6+10;
int n,f[maxn],fl;
char s[maxn];
int dfs(int st)
{
if(f[st])
return 0;
if(s[st]=='1')
return 0;
if(st==(1<<(n))-1)
return 1;
int fl=0;
_F(i,1,n)
{
if(!((1<<(i-1))&st))
fl|=dfs(st|(1<<(i-1)));
if(fl==1)
return 1;
}
f[st]=1;
return 0;
}
void work()
{
scanf("%d",&n);
scanf("%s",s+1);
memset(f,0,4*((1<<n)+10));
if(dfs(0))
puts("Yes");
else
puts("No");
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
work();
return 0;
}
Submission Info
| Submission Time |
|
| Task |
C - Mixture |
| User |
adolphshi |
| Language |
C++ 20 (gcc 12.2) |
| Score |
350 |
| Code Size |
831 Byte |
| Status |
AC |
| Exec Time |
24 ms |
| Memory |
5164 KiB |
Compile Error
Main.cpp: In function ‘void work()’:
Main.cpp:39:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
Main.cpp:40:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
40 | scanf("%s",s+1);
| ~~~~~^~~~~~~~~~
Main.cpp: In function ‘int main()’:
Main.cpp:50:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
50 | scanf("%d",&t);
| ~~~~~^~~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
350 / 350 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample_01.txt |
| All |
sample_01.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt |
| Case Name |
Status |
Exec Time |
Memory |
| sample_01.txt |
AC |
1 ms |
3660 KiB |
| test_01.txt |
AC |
6 ms |
3760 KiB |
| test_02.txt |
AC |
6 ms |
3640 KiB |
| test_03.txt |
AC |
7 ms |
3636 KiB |
| test_04.txt |
AC |
8 ms |
3768 KiB |
| test_05.txt |
AC |
24 ms |
4924 KiB |
| test_06.txt |
AC |
7 ms |
3688 KiB |
| test_07.txt |
AC |
5 ms |
4404 KiB |
| test_08.txt |
AC |
8 ms |
3876 KiB |
| test_09.txt |
AC |
4 ms |
4932 KiB |
| test_10.txt |
AC |
6 ms |
3684 KiB |
| test_11.txt |
AC |
3 ms |
5164 KiB |
| test_12.txt |
AC |
5 ms |
3584 KiB |
| test_13.txt |
AC |
15 ms |
4468 KiB |
| test_14.txt |
AC |
8 ms |
3644 KiB |
| test_15.txt |
AC |
21 ms |
4328 KiB |
| test_16.txt |
AC |
7 ms |
3824 KiB |
| test_17.txt |
AC |
3 ms |
5036 KiB |
| test_18.txt |
AC |
4 ms |
3764 KiB |
| test_19.txt |
AC |
3 ms |
4968 KiB |
| test_20.txt |
AC |
8 ms |
3656 KiB |
| test_21.txt |
AC |
3 ms |
4928 KiB |
| test_22.txt |
AC |
7 ms |
3568 KiB |
| test_23.txt |
AC |
2 ms |
5036 KiB |
| test_24.txt |
AC |
5 ms |
3692 KiB |