結果
| 問題 | No.2481 Shiritori |
| コンテスト | |
| ユーザー |
ococonomy1
|
| 提出日時 | 2023-09-22 22:07:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 3,154 bytes |
| コンパイル時間 | 1,144 ms |
| コンパイル使用メモリ | 112,544 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 01:51:11 |
| 合計ジャッジ時間 | 1,906 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using lg = long long;
using pii = pair<int, int>;
using pll = pair<lg, lg>;
#define TEST cerr << "TEST" << endl
//#define AMARI 998244353
#define AMARI 1000000007
#define TEMOTO ((sizeof(long double) == 16) ? false : true)
#define TIME_LIMIT 1980 * (TEMOTO ? 1 : 1000)
#define el '\n'
#define El '\n'
//trueなら先手が勝つ
//とりあえずm=2で考えるか
set<string> st;
int n = 3,m = 3;
bool saisyo = false;
//siritori(s) = その状況で文字sを言った時に勝てるか trueなら先手の勝ち
bool siritori(string const& s){
if(false){
cerr << s << el;
for(auto it = st.begin(); it != st.end(); it++){
cerr << *it << ' ';
}
cerr << el;
}
string temp;
temp.resize(m);
temp[0] = s.back();
bool kati = false;
for(int i = 0; i < n; i++){
temp[1] = 'a' + i;
for(int j = 0; j < n; j++){
temp[2] = 'a' + j;
if(st.find(temp) != st.end())continue;
st.insert(temp);
if(!siritori(temp))kati = true;
st.erase(temp);
if(kati)break;
}
if(kati)break;
}
//if(st.size() == 3 && kati == false && saisyo)TEST;
if(kati)return false;
else return true;
}
#define MULTI_TEST_CASE false
void solve(void) {
lg n,m;
cin >> n >> m;
if(n == 1 || m == 1){
//先手が何を言っても後手はすぐ何も言えない
cout << "First" << el;
return;
}
if(m == 2){
//先手がaaを言う→後手がaxを言う→先手がxaを言う……で先手の勝ち
cout << "First" << el;
return;
}
//aaa→axy→yxa としたいがy==aの時この限りではない
//仮説:回文が偶数なら後手、回文が奇数なら先手の勝ち?
if(n % 2 == 0){
cout << "Second" << el;
return;
}
cout << "First" << el;
return;
}
void calc(void) {
bool sente = false;
string s;
s.resize(m);
saisyo = true;
for(int i = 0; i < n; i++){
s[0] = 'a' + i;
for(int j = 0; j < n; j++){
s[1] = 'a' + j;
for(int k = 0; k < n; k++){
s[2] = 'a' + k;
cerr << s << el;
st.clear();
st.insert(s);
if(siritori(s))sente = true;
saisyo = false;
if(sente)break;
}
if(sente)break;
}
if(sente)break;
}
if(sente)cout << "First" << el;
else cout << "Second" << el;
return;
}
int main(void) {
cin.tie(nullptr);
ios::sync_with_stdio(false);
//calc();
int t = 1;
if(MULTI_TEST_CASE) cin >> t;
while(t--) {
solve();
}
return 0;
}
ococonomy1