提出 #19404646


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<long long>;
using pll = pair<long long, long long>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

constexpr long long mod = 1000000007;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define repi(i, a, b) for (ll i = a; i < b; i++)

#define all(x) (x).begin(), (x).end()

map<char, int> mp;

char f(char a, char b) {
    if (mp[a] == mp[b])
        return a;

    if (mp[a] > mp[b]) {
        swap(a, b);
    }

    if (mp[a] < mp[b]) {
        if (mp[a] * mp[b] == 0) {
            return a;
        } else {
            return b;
        }
    }
    return 0;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    mp['R'] = 0;
    mp['S'] = 1;
    mp['P'] = -1;

    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    while (k > 0) {
        s = s + s;
        string temp;
        for (int i = 0; i < s.size(); i += 2) {
            temp += f(s[i], s[i + 1]);
        }
        s = temp;
        k--;
    }
    cout << s[0] << endl;
}

提出情報

提出日時
問題 C - Large RPS Tournament
ユーザ himajin008
言語 C++ (GCC 9.2.1)
得点 500
コード長 1174 Byte
結果 AC
実行時間 9 ms
メモリ 3664 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:57:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   57 |         for (int i = 0; i < s.size(); i += 2) {
      |                         ~~^~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 3
AC × 26
セット名 テストケース
Sample sample.txt, sample_2.txt, sample_3.txt
All P.txt, R.txt, S.txt, max.txt, max_10.txt, max_2.txt, max_3.txt, max_4.txt, max_5.txt, max_6.txt, max_7.txt, max_8.txt, max_9.txt, random.txt, random_10.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, sample.txt, sample_2.txt, sample_3.txt
ケース名 結果 実行時間 メモリ
P.txt AC 9 ms 3564 KiB
R.txt AC 3 ms 3660 KiB
S.txt AC 3 ms 3464 KiB
max.txt AC 4 ms 3612 KiB
max_10.txt AC 2 ms 3628 KiB
max_2.txt AC 3 ms 3656 KiB
max_3.txt AC 2 ms 3576 KiB
max_4.txt AC 2 ms 3468 KiB
max_5.txt AC 3 ms 3524 KiB
max_6.txt AC 3 ms 3580 KiB
max_7.txt AC 2 ms 3524 KiB
max_8.txt AC 3 ms 3664 KiB
max_9.txt AC 2 ms 3564 KiB
random.txt AC 3 ms 3512 KiB
random_10.txt AC 2 ms 3588 KiB
random_2.txt AC 2 ms 3584 KiB
random_3.txt AC 2 ms 3656 KiB
random_4.txt AC 2 ms 3600 KiB
random_5.txt AC 2 ms 3464 KiB
random_6.txt AC 2 ms 3528 KiB
random_7.txt AC 3 ms 3620 KiB
random_8.txt AC 4 ms 3520 KiB
random_9.txt AC 3 ms 3632 KiB
sample.txt AC 3 ms 3576 KiB
sample_2.txt AC 2 ms 3464 KiB
sample_3.txt AC 2 ms 3580 KiB