QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#719800 | #2549. King's Palace | 369Pai | WA | 0ms | 3660kb | C++23 | 891b | 2024-11-07 09:01:15 | 2024-11-07 09:01:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 25 , C = 3;
int n , m; ll ans , lim[N][C] , hi[N];
map<ull , ll>mp[N];
ll Dfs(ll x , ll st)
{
if(x < 0)return 1;
if(mp[x].find(st) != mp[x].end())
return mp[x][st];
ll ans = 0;
for(int c = 0 ; c < 3 ; c++)
if(x == n - 1 || ((~st >> (x * 3 + c)) & 1))
ans += Dfs(x - 1 , (st & hi[x]) | lim[x][c]);
return mp[x][st] = ans;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0) , cout.tie(0);
cin >> n >> m;
for(int i = 1 ; i <= m ; i++)
{
int a , x , b , y;
cin >> a >> x >> b >> y;
// cerr << i << ":" << a - 1 << ' ' << x << ' ' << b - 1 << ' ' << y << "\n";
lim[--b][y] |= (1ull << ((--a) * 3 + x));
}
hi[0] = 0;
for(int i = 1 ; i < n ; i++)
hi[i] = hi[i - 1] << 3 | 7;
cout << Dfs(n - 1 , 0) << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3660kb
input:
2 3 1 R 2 R 1 G 2 R 1 B 2 G
output:
8
result:
wrong answer expected '6', found '8'