답안 #1089216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1089216 2024-09-16T07:31:21 Z vjudge1 Growing Vegetable is Fun 3 (JOI19_ho_t3) C++17
0 / 100
1 ms 348 KB
#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

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++){
      |                    ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -