Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
747 B
2
Indexable
Never

#include <bits/stdc++.h>

using namespace std;

ifstream fin("palindrom_ciclic.in");
ofstream fout("palindrom_ciclic.out");

int n, v[1005], cnt;
bool isPalindrom=false;

void citire(){
    fin>>n;
    for(int i=0; i<n; i++){
        fin>>v[i];
    }
}

bool verif(){
    for(int i=0; i<n; i++){
        if(v[i]!=v[n-i-1]){
          return false;  
        } 
    }
    isPalindrom=true;
    return true;
}

void permutari(){
    int a=v[0];
    for(int i=0; i<n-1; i++){
        v[i]=v[i+1];
    }
    v[n-1]=a;
    cnt++;
}

void solve(){
    while(!verif() && cnt<n){
        permutari();
    }
    if(isPalindrom){
        fout<<"DA "<<cnt;
    }
    else{
        fout<<"NU";
    }
}

int main(){
    citire();
    solve();
    return 0;
}