首页 > 代码库 > Codeforces Round #243 (Div. 2) B. Sereja and Mirroring

Codeforces Round #243 (Div. 2) B. Sereja and Mirroring

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int> > a(n,vector<int>(m,0));
    for(int i = 0; i < n; ++ i){
        for(int j = 0 ; j < m ; ++ j){
            cin >> a[i][j];
        }
    }
    if(n%2) cout<<n<<endl;
    else{
        int left= 0 ,right =n-1, preRight = n-1;
        while(left < right){
            if(a[left] != a[right]) break;
            else left++,right--;
            if(left-1 == right) left = 0,preRight = right;
        }
        cout<<preRight+1<<endl;
    }
}