結果
問題 | No.1405 ジグザグロボット |
ユーザー | SSRS |
提出日時 | 2020-12-08 22:51:55 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,260 bytes |
コンパイル時間 | 1,742 ms |
コンパイル使用メモリ | 178,636 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-16 23:27:52 |
合計ジャッジ時間 | 7,977 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | WA | - |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | WA | - |
testcase_10 | AC | 3 ms
6,944 KB |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | WA | - |
testcase_14 | AC | 3 ms
6,940 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 2 ms
6,944 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 3 ms
6,944 KB |
testcase_32 | AC | 2 ms
6,940 KB |
testcase_33 | WA | - |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 4 ms
6,944 KB |
testcase_36 | AC | 2 ms
6,940 KB |
testcase_37 | AC | 2 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N, X, Y; cin >> N >> X >> Y; string S; cin >> S; int Scnt = 0; for (int i = 0; i < N; i++){ if (S[i] == 'S'){ if (Scnt >= Y){ S[i] == '.'; } Scnt++; } } if (Y > Scnt){ cout << -1 << endl; } else { vector<string> T; T.push_back(""); for (int i = 0; i < N; i++){ if (S[i] == 'L' || S[i] == 'R'){ T.back() += S[i]; } else if (S[i] == 'S' && T.size() <= Y){ T.push_back(""); } } int cnt = T.size(); /* cout << "cnt = " << cnt << endl; for (int i = 0; i < cnt; i++){ cout << i << " " << T[i] << endl; } */ vector<int> left(cnt), right(cnt), sum(cnt); for (int i = 0; i < cnt; i++){ int sz = T[i].size(); left[i] = 0, right[i] = 0, sum[i] = 0; for (int j = 0; j < sz; j++){ if (T[i][j] == 'L'){ left[i]--; right[i]--; sum[i]--; } if (T[i][j] == 'R'){ left[i]++; right[i]++; sum[i]++; } left[i] = min(left[i], 0); right[i] = max(right[i], 0); //cout << "sum[i] = " << sum[i] << ", left[i] = " << left[i] << ", right[i] = " << right[i] << endl; } //cout << "sum[i] = " << sum[i] << ", left[i] = " << left[i] << ", right[i] = " << right[i] << endl; } int Rsum = 0; for (int i = 0; i < cnt; i++){ Rsum += right[i]; } //cout << "Rsum = " << Rsum << endl; if (X > Rsum){ cout << -1 << endl; } else { vector<pair<int, int>> ob; int currX = 0; for (int i = 0; i < cnt; i++){ if (currX + right[i] <= X){ ob.push_back(make_pair(currX - 1, i)); currX += right[i]; } else if (currX == X){ ob.push_back(make_pair(currX - 1, i)); ob.push_back(make_pair(currX + 1, i)); } else { ob.push_back(make_pair(currX - 1 - (X - currX - right[i]), i)); } } if (Y < Scnt){ ob.push_back(make_pair(X, Y + 1)); } int M = ob.size(); cout << M << endl; for (int i = 0; i < M; i++){ cout << ob[i].first << ' ' << ob[i].second << endl; } } } }