結果
| 問題 |
No.2285 Make A Unit Square
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2023-04-28 21:55:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 143 ms / 2,000 ms |
| コード長 | 2,214 bytes |
| コンパイル時間 | 1,197 ms |
| コンパイル使用メモリ | 119,816 KB |
| 最終ジャッジ日時 | 2025-02-12 15:07:45 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
コンパイルメッセージ
main.cpp: In function ‘int mex(std::vector<int>)’:
main.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
53 | }
| ^
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
if(v.empty()) {
cout << endl;
return;
}
for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
cout << v.back() << endl;
}
int mex(vector<int> v){
int n = v.size();
vector<bool> used(n+1);
for(int x: v){
if(x <= n) used[x] = true;
}
for(int i = 0; i <= n; i++){
if(!used[i]) return i;
}
}
vector<int> calc(int n){
vector<int> g(n+1);
for(int x = 4; x <= n; x++){
vector<int> v;
for(int l = 2; l+2 <= x; l++){
int r = x-l;
v.push_back(g[l]^g[r]);
}
g[x] = mex(v);
}
// for(int i = 0; i <= n; i++){
// cout << g[i] << ' ';
// if(i%34 == 0) cout << endl;
// }
return g;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
auto g = calc(500);
auto grundy = [&](int x){
if(x < g.size()) return g[x];
x %= 34;
x += 34*5;
return g[x];
};
int t; cin >> t;
while(t--){
int a, b; cin >> a >> b;
ll x = grundy(a)^grundy(b);
if(x == 0) cout << "Second" << endl;
else cout << "First" << endl;
}
}
milanis48663220