Submission #1107333

#TimeUsernameProblemLanguageResultExecution timeMemory
1107333vjudge1Growing Vegetable is Fun 3 (JOI19_ho_t3)C++17
0 / 100
1129 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define nn "\n"; #define pb push_back #define all(v) (v).begin() , (v).end() const int N = 2e4+ 4; int n , T , q , m ; signed main(){ cin>> n ; string s ; cin>> s ; int ko =0 ; for(int i=0 ; i < s.size() - 1; i++){ if(s[i]==s[i+1])ko = 1; } if(!ko){ cout << 0 ; return 0 ; } queue<pair<string , int >>q; q.push({s , 0 }); while(q.size()){ string v = q.front().first; int c = q.front().second; q.pop(); if(c > n+5)continue; int ok =0 ; for(int i=0 ; i < v.size() - 1; i++){ if(v[i]==v[i+1]){ ok = 1; } swap(v[i], v[i+1]); q.push({v , c + 1 }); swap(v[i] , v[i+1]); } if(!ok){ cout <<c; return 0 ; } } cout <<-1 ; }

Compilation message (stderr)

joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:14:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0 ; i < s.size() - 1; i++){
      |                   ~~^~~~~~~~~~~~~~
joi2019_ho_t3.cpp:29:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int i=0 ; i < v.size() - 1; i++){
      |                       ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...