Submission #569552

# Submission time Handle Problem Language Result Execution time Memory
569552 2022-05-27T13:44:25 Z esomer Miners (IOI07_miners) C++17
16 / 100
3 ms 720 KB
#include<bits/stdc++.h>

using namespace std;

#define endl "\n"

const int MOD = 1e9 + 7;

void solve(){
    int n; cin >> n;
    string s; cin >> s;
    string s1;
    s1 += s[0];
    string s2;
    for(int i = 1; i < n; i++){
        bool eq = 1;
        for(int j = i - 1; j >= i - 2 && j >= 0; j--){
            if(s[i] != s[j]) eq = 0;
        }
        if(eq) s2 += s[i];
        else s1 += s[i];
    }
    int ans = 0;
    for(int i = 0; i < s1.size(); i++){
        bool one = 0;
        bool two = 0;
        bool three = 0;
        for(int j = i; j >= 0 && j >= i - 2; j--){
            if(s1[j] == 'F'){
                if(!one){
                    ans++;
                    one = 1;
                }
            }else if(s1[j] == 'M'){
                if(!two){
                    ans++;
                    two = 1;
                }
            }else if(!three){
                ans++;
                three = 1;
            }
        }
    }
    for(int i = 0; i < s2.size(); i++){
        bool one = 0;
        bool two = 0;
        bool three = 0;
        for(int j = i; j >= 0 && j >= i - 2; j--){
            if(s2[j] == 'F'){
                if(!one){
                    ans++;
                    one = 1;
                }
            }else if(s2[j] == 'M'){
                if(!two){
                    ans++;
                    two = 1;
                }
            }else if(!three){
                ans++;
                three = 1;
            }
        }
    }
    cout << ans << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //int tt; cin >> tt;
    int tt = 1;
    for(int i = 1; i <= tt; i++) solve();

    return 0;
}

Compilation message

miners.cpp: In function 'void solve()':
miners.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 0; i < s1.size(); i++){
      |                    ~~^~~~~~~~~~~
miners.cpp:45:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i = 0; i < s2.size(); i++){
      |                    ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 720 KB Output isn't correct
2 Halted 0 ms 0 KB -