Skip to content

Commit f5dc144

Browse files
committed
Create 1794A-PrefixAndSuffixArray.cpp
1 parent 57eccb5 commit f5dc144

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

1794A-PrefixAndSuffixArray.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
#include <algorithm>
3+
4+
int main(){
5+
6+
std::ios_base::sync_with_stdio(false);
7+
long t; std::cin >> t;
8+
while(t--){
9+
long n; std::cin >> n;
10+
std::string x(""), y("");
11+
for(long p = 0; p < 2 * n - 2; p++){
12+
std::string cur; std::cin >> cur;
13+
if(cur.size() == n - 1){
14+
if(x.size() == 0){x = cur;}
15+
else{y = cur;}
16+
}
17+
}
18+
19+
std::reverse(x.begin(), x.end());
20+
std::cout << (x == y ? "YES" : "NO") << std::endl;
21+
}
22+
23+
}

0 commit comments

Comments
 (0)