Submission #1089216

#TimeUsernameProblemLanguageResultExecution timeMemory
1089216vjudge1Growing Vegetable is Fun 3 (JOI19_ho_t3)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> //qwerty47924692 using namespace std; using ll = long long; #define f first #define s second const ll N=3e5+29; ll dp[65][4000][3],n,a[N],ans=0; string s; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>s; bool ch=1; ll k=1000; while(ch&&k--){ for(ll i=1;i<s.size()-1;i++){ if(s[i]==s[i-1]&&s[i]!=s[i+1]){ ans++; swap(s[i],s[i+1]); } if(s[i]==s[i+1]&&s[i]!=s[i-1]){ ans++; swap(s[i],s[i-1]); } } ch=0; for(ll i=1;i<s.size();i++){ if(s[i]==s[i-1])ch=1; } } if(k==-1){ cout<<k; } else cout<<ans; }

Compilation message (stderr)

joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:18:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for(ll i=1;i<s.size()-1;i++){
      |                    ~^~~~~~~~~~~
joi2019_ho_t3.cpp:30:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for(ll i=1;i<s.size();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...