QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#593703 | #4637. Cell Tower | ucup-team3161# | WA | 1ms | 4108kb | C++14 | 1.2kb | 2024-09-27 15:32:33 | 2024-09-27 15:32:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define pct __builtin_popcountll
#define eb emplace_back
int n,a[64];string b;vector<ull> vc[64];
priority_queue<ull,vector<ull>,greater<ull>> q;
map<string,bool> vs;unordered_map<ull,ull> dp;
bool chk(ull x)
{
string t;
for(int i=0;i<64;++i)
if(x>>i&1) t+=a[i]+'0';return vs[t];
}
void dfs(int o,ull x)
{
if(chk(x)) vc[o].eb(x);
if(pct(x)<4) for(int i=0;i<64;++i) if(x>>i&1)
{
if(i%8 && i-1>o && !(x>>i-1&1)) dfs(o,x|(1ull<<i-1));
if(i%8<7 && i+1>o && !(x>>i+1&1)) dfs(o,x|(1ull<<i+1));
if(i/8 && i-8>o && !(x>>i-8&1)) dfs(o,x|(1ull<<i-8));
if(i/8<7 && i+8>o && !(x>>i+8&1)) dfs(o,x|(1ull<<i+8));
}
}
int main()
{
ios::sync_with_stdio(0);
for(int i=0;i<64;++i) cin>>a[i];
for(int i=1;i<=n;++i) cin>>b,vs[b]=1;
q.push(0);dp[0]=1;
for(int i=0;i<64;++i)
{
dfs(i,1ull<<i);sort(vc[i].begin(),vc[i].end());
vc[i].resize(unique(vc[i].begin(),vc[i].end())-vc[i].begin());
}
while(!q.empty())
{
ull x=q.top();q.pop();
for(int i=0;i<64;++i) if(!(x>>i&1))
{
for(auto j:vc[i]) if(!(x&j))
{
ull y=x|j;if(!dp.count(y)) q.push(y);
dp[y]+=dp[x];
}
break;
}
}
printf("%llu\n",dp[(ull)(-1)]);return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4108kb
input:
1 1 1 1 2 3 3 3 0 4 4 4 2 2 2 3 0 0 5 5 6 6 7 7 0 9 5 5 6 8 7 7 9 9 9 1 6 8 8 8 3 1 1 1 2 2 2 2 4 5 6 0 0 4 4 3 7 8 9 0 0 4 3 3 16 1111 2222 3333 444 0000 5555 6666 7777 8888 9999 111 333 3456 789 3478 569
output:
0
result:
wrong answer 1st lines differ - expected: '2', found: '0'