-
Notifications
You must be signed in to change notification settings - Fork 0
/
da_pra_ver.cpp
86 lines (74 loc) · 1.76 KB
/
da_pra_ver.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
using namespace std;
int main() {
int n, m, i, j, k, solutions = 0;
cin >> n;
cin >> m;
char mat[n][m];
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
cin >> mat[i][j];
}
}
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
if (mat[i][j] == 'D') {
for (k = i; k < n; k++) {
if (mat[k][j] != '#') {
mat[k][j] = 'V';
}
else {
break;
}
}
}
if (mat[i][j] == 'L') {
for (k = j; k >= 0; k--) {
if (mat[i][k] != '#') {
mat[i][k] = 'V';
}
else {
break;
}
}
}
if (mat[i][j] == 'R') {
for (k = j; k < m; k++) {
if (mat[i][k] != '#') {
mat[i][k] = 'V';
}
else {
break;
}
}
}
if (mat[i][j] == 'U') {
for (k = i; k >= 0; k--) {
if (mat[k][j] != '#') {
mat[k][j] = 'V';
}
else {
break;
}
}
}
}
}
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
if (mat[i][j] == '.') {
solutions++;
}
}
}
if (solutions == 0) {
cout << "NO SOLUTION" << endl;
}
if (solutions == 1) {
cout << "ONLY ONE SOLUTION" << endl;
}
if (solutions > 1) {
cout << "MULTIPLE SOLUTIONS" << endl;
}
return 0;
}