-
Notifications
You must be signed in to change notification settings - Fork 4
/
Lv4_단체사진찍기.cpp
42 lines (38 loc) · 835 Bytes
/
Lv4_단체사진찍기.cpp
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
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(int n, vector<string> data) {
int answer = 0;
string friends = "ACFJMNRT";
string arr;
do {
arr = "";
for (int i = 0; i < 8; i++)
arr += friends[i];
bool flag = true;
for (int i = 0; i < data.size(); i++) {
char f1 = data[i][0];
char f2 = data[i][2];
char con = data[i][3];
int diff = data[i][4] - '0';
int pos1 = arr.find(f1);
int pos2 = arr.find(f2);
if (con == '>') {
if (abs(pos1 - pos2) - 1 <= diff)
flag = false;
}
else if (con == '<') {
if (abs(pos1 - pos2) - 1 >= diff)
flag = false;
}
else {
if (abs(pos1 - pos2) - 1 != diff)
flag = false;
}
}
if (flag)
++answer;
} while (next_permutation(friends.begin(), friends.end()));
return answer;
}