-
Notifications
You must be signed in to change notification settings - Fork 0
/
Consecutive_Cuts_A1.cpp
57 lines (50 loc) · 1.43 KB
/
Consecutive_Cuts_A1.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
//
// Created by Tony on 9/10/2022.
//
#include <bits/stdc++.h>
using namespace std;
int main(){
freopen("consecutive_cuts_chapter_1_input.txt","r",stdin);
freopen("consecutive_cuts_chapter_1_output.txt","w",stdout);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
int c, k;
cin >> c >> k;
vector<int> cards(c,0);
vector<int> lcirc(c,0);
for (int j = 0; j < c; j++) cin >> cards[j];
for (int j = 0; j < c; j++) cin >> lcirc[j];
int si = 0;
for (int k = 0; k < c; k++)
if (cards[k] == lcirc[si]){
si = k;
break;
}
int id = si;
bool works = true;
for (int k = 0; k < c; k++) {
if (k != 0 && id == si)
break;
if (id == c)
id = 0;
if (cards[id] != lcirc[k])
works = false;
id++;
}
cout << "Case #" << i << ": ";
// si is the max # of items I can cut to get a perfect
if (!works || (si == 1 && k == 2 && c == 2) || (k == 0 && si != 0) || (si == 0 && k == 1))
cout << "NO" << endl;
else
cout << "YES" << endl;
// cout << c << " " << k << endl;
// for (int j : cards)
// cout << j << " ";
// cout<<endl;
// for (int j : lcirc)
// cout << j << " ";
// cout<<endl;
}
return 0;
}