QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#620509 | #2549. King's Palace | sjzsd147 | RE | 0ms | 3912kb | C++14 | 1.4kb | 2024-10-07 18:41:32 | 2024-10-07 18:41:32 |
Judging History
answer
#include<bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
using namespace std;
typedef long long ll;
int n,m;
vector<int>req[25][3][2];
bool use[463];
bool bacinf[25][3];
ll dfs(int p){
if(p>n){
return 1;
}
bool ava[3]={1,1,1};
for(int i=0;i<3;i++){
for(auto j:req[p][i][1]){
if(!use[j]){
ava[i]=0;
break;
}
}
}
if(!ava[0]&&!ava[1]&&!ava[2]) return 0;
// for(int i=0;i<3;i++){
// for(auto j:req[p][i][0]){
// use[j]=1;
// }
// }
int cnt=0;
for(int i=0;i<3;i++){
if(ava[i]&&!bacinf[p][i]){
cnt++;
}
}
ll res=cnt?dfs(p+1)*cnt:0;
for(int i=0;i<3;i++){
if(!ava[i]||!bacinf[p][i]) continue;
for(auto j:req[p][i][0]){
use[j]=0;
}
res+=dfs(p+1);
for(auto j:req[p][i][0]){
use[j]=1;
}
}
return res;
}
inline int change(char c){
if(c=='R') return 0;
if(c=='G') return 1;
return 2;
}
int main(){
// freopen("paint.in","r",stdin);
// freopen("paint.out","w",stdout);
// ios::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++){
use[i]=1;
int a,b,x,y;
char tmpx,tmpy;
scanf("%d",&a);
getchar();
tmpx=getchar();
scanf("%d",&b);
getchar();
tmpy=getchar();
x=change(tmpx);
y=change(tmpy);
req[a][x][0].push_back(i);
bacinf[a][x]=1;
req[b][y][1].push_back(i);
}
printf("%lld\n",dfs(1));
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
input:
2 3 1 R 2 R 1 G 2 R 1 B 2 G
output:
6
result:
ok answer is '6'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
1 0
output:
3
result:
ok answer is '3'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
22 0
output:
31381059609
result:
ok answer is '31381059609'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
4 12 2 R 3 R 1 B 2 B 2 R 3 B 3 R 4 R 1 B 4 G 1 R 3 B 3 G 4 B 2 G 3 G 1 B 2 R 1 G 2 R 1 R 3 G 1 G 3 B
output:
13
result:
ok answer is '13'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
2 4 1 G 2 G 1 B 2 R 1 R 2 G 1 B 2 B
output:
5
result:
ok answer is '5'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
5 77 3 B 5 B 2 G 5 G 4 R 5 G 1 G 2 B 1 R 4 R 4 B 5 G 2 B 3 G 2 G 5 B 1 R 3 G 2 R 5 R 3 B 4 R 1 R 2 B 3 G 4 G 1 B 5 G 3 R 5 G 3 G 4 B 1 B 4 G 4 B 5 R 2 R 4 G 1 G 4 B 2 G 3 R 2 R 5 B 1 G 2 R 2 B 4 R 2 R 3 R 3 B 5 G 2 G 3 G 1 R 3 R 1 R 5 G 2 G 3 B 3 B 4 B 4 R 5 B 1 R 2 G 3 G 5 R 1 R 2 R 2 B 5 B 3 B 5 R...
output:
0
result:
ok answer is '0'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
10 141 3 B 9 B 1 R 8 R 4 B 8 R 2 B 4 R 2 R 7 B 6 B 9 R 1 R 9 R 4 R 8 G 3 B 8 R 3 B 5 G 4 B 9 B 4 G 5 R 2 R 3 G 7 B 8 G 5 B 7 R 7 B 8 R 2 B 8 B 7 R 10 B 2 G 10 G 6 G 8 B 1 R 4 B 8 R 10 B 2 G 3 B 2 B 5 B 3 R 4 R 3 B 7 R 3 R 7 R 2 R 10 R 3 G 9 G 5 B 10 G 6 R 8 B 3 R 9 G 1 B 10 G 3 R 8 G 1 B 3 R 4 R 9 R...
output:
0
result:
ok answer is '0'
Test #8:
score: -100
Runtime Error
input:
22 2079 1 R 2 R 1 R 2 G 1 R 2 B 1 G 2 R 1 G 2 G 1 G 2 B 1 B 2 R 1 B 2 G 1 B 2 B 1 R 3 R 1 R 3 G 1 R 3 B 1 G 3 R 1 G 3 G 1 G 3 B 1 B 3 R 1 B 3 G 1 B 3 B 1 R 4 R 1 R 4 G 1 R 4 B 1 G 4 R 1 G 4 G 1 G 4 B 1 B 4 R 1 B 4 G 1 B 4 B 1 R 5 R 1 R 5 G 1 R 5 B 1 G 5 R 1 G 5 G 1 G 5 B 1 B 5 R 1 B 5 G 1 B 5 B 1 R ...