답안 #1107330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1107330 2024-11-01T06:18:43 Z vjudge1 Growing Vegetable is Fun 3 (JOI19_ho_t3) C++17
0 / 100
1 ms 336 KB
#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 ;
    }
    vector<pair<int , string>>v;
    for(int i=0 ; i < ( 1 << n ) ; i++){
            string t = s;
            int c =0 ;
        for(int j =0 ; j < s.size() ; j++){
            if(j < s.size() -1 && ( i >> j )&1 ){
                swap(t[j] , t[j+1]);
                c++;
            }
        }
        int ok =0 ;
        for(int j=0 ; j < t.size() - 1; j++){
            if(t[j]==t[j+1]){
                ok = 1;
                break;
            }
        }
        if(!ok)v.pb({c , t});
    }
    if(!v.size()){
            cout <<-1;
            return 0 ;
    }else {
    sort(all(v));
    for(auto it:v){
        cout << it.second ;
        return 0 ;
    }
    }
}

Compilation message

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:25:26: 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]
   25 |         for(int j =0 ; j < s.size() ; j++){
      |                        ~~^~~~~~~~~~
joi2019_ho_t3.cpp:26:18: 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]
   26 |             if(j < s.size() -1 && ( i >> j )&1 ){
      |                ~~^~~~~~~~~~~~~
joi2019_ho_t3.cpp:32: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]
   32 |         for(int j=0 ; j < t.size() - 1; j++){
      |                       ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -