题解:CF634A Island Puzzle
思路:
由于
代码:
#include<iostream>
using namespace std;
int n, s[200005], s1[200005], t, k;
int main()
{
cin >> n;
for(int i = 1; i <= n; i++)
{
int x;
cin >> x;
if(x != 0)
{
s[++t] = x;
}
}
t = 0;
for(int i = 1; i <= n; i++)
{
int x;
cin >> x;
if(x != 0)
{
s1[++t] = x;
}
if(s1[t] == s[1])
{
k = t;
}
}
for(int i = 1; i <= t; i++)
{
if(s[i] != s1[k])
{
cout << "NO";
return 0;
}
k = k % t + 1;
}
cout << "YES";
return 0;
}
希望管理员审核通过