-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhackercup_20_travel_restriction.cpp
More file actions
87 lines (78 loc) · 1.55 KB
/
hackercup_20_travel_restriction.cpp
File metadata and controls
87 lines (78 loc) · 1.55 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
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
87
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solv()
{
int n;
cin >> n;
string a, b;
cin >> a >> b;
vector<vector<char>> ans(n, vector<char>(n, 'Y'));
/*
**
NYYYNNYYYY
YYNYYNYYNY
NYYYNNNNNN
NYYYYNNNNN
*/
for (int i = 0; i < n; ++i)
{
bool isValid = b[i] == 'N' ? false : true;
for (int j = i+1; j < n; ++j)
{
if (isValid && a[j] == 'Y')
{
if (b[j] == 'Y')
{
isValid = true;
}
else{
isValid = false;
}
}
else
{
ans[i][j] = 'N';
isValid = false;
}
}
isValid = b[i] == 'N' ? false : true;
for (int j = i - 1; j >= 0; --j)
{
if(isValid && a[j] == 'Y'){
if(b[j] == 'Y' ){
continue;
}
else{
isValid = false;
}
}
else
{
ans[i][j] = 'N';
isValid = false;
}
}
}
for (auto x : ans)
{
for (auto y : x)
{
cout << y;
}
cout << endl;
}
}
int main()
{
freopen("file.in", "r", stdin);
freopen("output.txt", "w", stdout);
int tt;
cin >> tt;
for (int i = 1; i <= tt; ++i)
{
cout << "Case #" << i << ": " << endl;
;
solv();
}
}