結果
| 問題 |
No.3323 岩井星式ジャンケン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-22 12:47:36 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,577 bytes |
| コンパイル時間 | 2,570 ms |
| コンパイル使用メモリ | 281,448 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-22 12:47:41 |
| 合計ジャッジ時間 | 4,391 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 3 |
ソースコード
#include <bits/stdc++.h>
[[nodiscard]] static inline constexpr std::array<uint_fast32_t, 3> count([[maybe_unused]] const uint_fast32_t N, const uint_fast32_t i, const std::vector<std::string>& S) noexcept
{
std::array<uint_fast32_t, 3> count_of = { 0, 0, 0 };
for (const auto& s : S)
if (!s.empty())
{
[[assume(i < s.size())]];
switch (s[i])
{
case 'G':
++count_of[0];
break;
case 'C':
++count_of[1];
break;
case 'P':
++count_of[2];
break;
default: [[unlikely]]
break;
}
}
return count_of;
}
[[nodiscard]] static inline constexpr std::string solve(const uint_fast32_t N, const uint_fast32_t M, std::vector<std::string>& S) noexcept
{
std::string ans(M, 0);
for (uint_fast32_t i = 0; i != M; ++i)
{
const std::array<uint_fast32_t, 3> count_of = count(N, i, S);
if (count_of[0] == 0)
ans[i] = 'C';
else if (count_of[1] == 0)
ans[i] = 'P';
else if (count_of[2] == 0)
ans[i] = 'G';
else
return "-1";
for (auto& s : S)
if (!s.empty() && s[i] != ans[i])
s.clear();
}
for (const auto& s : S)
if (!s.empty())
{
[[assume(s == ans)]];
switch (s[M - 1])
{
case 'G':
ans[M - 1] = 'P';
break;
case 'C':
ans[M - 1] = 'G';
break;
case 'P':
ans[M - 1] = 'C';
break;
}
}
return ans;
}
int main()
{
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
uint_fast32_t N, M;
std::cin >> N >> M;
std::vector<std::string> S(N);
for (auto& s : S)
s.reserve(M), std::cin >> s;
std::cout << solve(N, M, S) << '\n';
return 0;
}