結果

問題 No.291 黒い文字列
ユーザー mayoko_mayoko_
提出日時 2015-10-16 22:49:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,912 bytes
コンパイル時間 611 ms
コンパイル使用メモリ 77,444 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 01:22:49
合計ジャッジ時間 1,882 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K = 0, U = 0, R = 0, O = 0, I = 0;
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    for (int i = 0; i < n; i++) {
        switch (s[i]) {
        case 'I':
            I++;
            break;
        case 'O':
            if (I > 0) {
                I--;
                O++;
            }
            break;
        case 'R':
            if (O > 0) {
                O--;
                R++;
            }
            break;
        case 'U':
            if (R > 0) {
                R--;
                U++;
            }
            break;
        case 'K':
            if (U > 0) {
                U--;
                K++;
            }
            break;
        case '?':
            if (U > 0) {
                U--;
                K++;
                break;
            }
            if (R > 0) {
                R--;
                U++;
                break;
            }
            if (O > 0) {
                O--;
                R++;
                break;
            }
            if (I > 0) {
                I--;
                O++;
                break;
            }
            I++;
            break;
            default:
                break;
        }
    }
    cout << K << endl;
    return 0;
}
0