Submission #67743197
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
const int N=3e5+10;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int n,m,k;
int a[N],b[N];
void slove(){
cin>>n;
string s=" ";cin>>s;
s=" "+s;
map<int,int> mp,mp1;
for(int i=1;i<s.size();i++){
if(s[i]=='1') {
mp[i]=1;
// cout<<i<<' '<<s[i]<<endl;
}
}
int f=0;
auto dfs=[&](auto &&self,int x)->void{
if(x==(1<<n)-1){
f=1;
return;
}
// cout<<x<<endl;
for(int i=0;i<n&&f==0;i++){
int t=x+(1<<i);
if(mp1[i]) continue;
else if(mp[t]) continue;
else{
mp1[i]=1;
// cout<<"&&"<<' '<<(1<<i)<<endl;
// cout<<i<<' '<<t<<endl;
self(self,t);
mp1[i]=0;
}
}
};
for(int i=0;i<n;i++){
if(mp[1<<i]) continue;
mp1[i]=1;
// cout<<i<<' '<<(1<<i)<<endl;
dfs(dfs,1<<(i));
if(f==1) break;
}
if(f==1){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T=1;
cin>>T;
while(T--){
slove();
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Mixture |
| User | Maikan |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 1353 Byte |
| Status | WA |
| Exec Time | 2211 ms |
| Memory | 19864 KiB |
Compile Error
Main.cpp: In function ‘void slove()’:
Main.cpp:15:18: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
15 | for(int i=1;i<s.size();i++){
| ~^~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 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 | 3408 KiB |
| test_01.txt | AC | 8 ms | 3520 KiB |
| test_02.txt | AC | 12 ms | 3516 KiB |
| test_03.txt | WA | 19 ms | 3444 KiB |
| test_04.txt | WA | 38 ms | 3380 KiB |
| test_05.txt | TLE | 2211 ms | 11248 KiB |
| test_06.txt | WA | 47 ms | 3448 KiB |
| test_07.txt | TLE | 2210 ms | 11308 KiB |
| test_08.txt | WA | 40 ms | 3528 KiB |
| test_09.txt | TLE | 2207 ms | 3488 KiB |
| test_10.txt | WA | 26 ms | 3460 KiB |
| test_11.txt | AC | 496 ms | 3772 KiB |
| test_12.txt | WA | 31 ms | 3652 KiB |
| test_13.txt | TLE | 2207 ms | 4032 KiB |
| test_14.txt | AC | 271 ms | 3536 KiB |
| test_15.txt | TLE | 2207 ms | 3584 KiB |
| test_16.txt | AC | 122 ms | 3528 KiB |
| test_17.txt | AC | 56 ms | 11152 KiB |
| test_18.txt | WA | 27 ms | 3532 KiB |
| test_19.txt | WA | 80 ms | 19864 KiB |
| test_20.txt | WA | 30 ms | 3524 KiB |
| test_21.txt | AC | 93 ms | 19812 KiB |
| test_22.txt | AC | 19 ms | 3520 KiB |
| test_23.txt | AC | 30 ms | 7452 KiB |
| test_24.txt | AC | 17 ms | 3384 KiB |