Skip to content

Instantly share code, notes, and snippets.

@lovasoa
Created April 10, 2018 16:18
Show Gist options
  • Save lovasoa/45d6d2b6745eedcee228360eed203d21 to your computer and use it in GitHub Desktop.
Save lovasoa/45d6d2b6745eedcee228360eed203d21 to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std;
bool is_mirror(int n) {
if (n<=0) return true;
int n1, n2;
cin >> n1;
if (n==1) return true;
bool inner_mirror = is_mirror(n-2);
cin >> n2;
return inner_mirror && n1 == n2;
}
int main(void) {
int n;
cin >> n;
cout << (is_mirror(n) ? "YES" : "NO") << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment