-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassign.cpp
More file actions
45 lines (45 loc) · 1.08 KB
/
assign.cpp
File metadata and controls
45 lines (45 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int n, arr[1001], total=0, k, cow1[10001], cow2[100001], counter=0;
char sd[100001];
void gen(int index){
if(index==n){
bool print=true;
for(int i=0; i<k; i++){
if(sd[i]=='S' and arr[cow1[i]-1]!=arr[cow2[i]-1]){
print=false;
}
else if(sd[i]=='D' and arr[cow1[i]-1]==arr[cow2[i]-1]){
print = false;
}
}
if(print==true){
// for(int i=0; i<n; i++){
// cout << arr[i];
// }
// cout <<arr[cow1[0]] <<" " << arr[cow2[0]] << endl;
// cout << cow2[0] << endl;
counter++;
}
return;
}
else{
for(int i=1; i<=3; i++){
arr[index]=i;
gen(index+1);
}
}
return;
}
int main(){
cin >> n >> k;
for(int i=0; i<k; i++){
cin >> sd[i] >> cow1[i] >> cow2[i];
}
gen(0);
cout << counter << endl;
}