Submission #950179

# Submission time Handle Problem Language Result Execution time Memory
950179 2024-03-20T06:30:48 Z ezzzay Growing Vegetable is Fun 3 (JOI19_ho_t3) C++14
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ss second
#define ff first
#define pb push_back
const int N=3e5+5;
int b[N];
int a[N];
map<string,int>mp;
signed main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    mp[s]=1;
    queue<string>q;
    q.push(s);
    while(!q.empty()){
        string a=q.front();
        q.pop();
        for(int i=0;i<n-1;i++){
            if(a[i]==a[i+1]){
                cout<<mp[a]-1;
                return 0;
            }
        }
        for(int i=0;i<n-1;i++){
            string b=a;
            swap(b[i],b[i+1]);
            if(mp[b]==0 ){
                mp[b]=mp[a]+1;
                q.push(b);
            }
        }
    }
    cout<<-1;
} 
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -