結果
| 問題 | No.3791 Full House Torus |
| コンテスト | |
| ユーザー |
ococonomy1
|
| 提出日時 | 2026-11-06 22:52:47 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 6,689 bytes |
| 記録 | |
| コンパイル時間 | 1,639 ms |
| コンパイル使用メモリ | 226,708 KB |
| 実行使用メモリ | 21,520 KB |
| 最終ジャッジ日時 | 2026-11-06 22:53:04 |
| 合計ジャッジ時間 | 3,331 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 4 WA * 7 |
ソースコード
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
#define MOD 998244353
//#define MOD 1000000007
#define el '\n'
#define El '\n'
#define YESNO(x) ((x) ? "Yes" : "No")
#define YES YESNO(true)
#define NO YESNO(false)
#define EXIT_ANS(x) {cout << (x) << '\n'; return;}
template <typename T> void inline SORT(T &v){sort(v.begin(),v.end()); return;}
template <typename T> void inline REV(T &v){reverse(v.begin(),v.end()); return;}
template <typename T> void inline VEC_UNIQ(T &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); return;}
template <typename T> auto inline MAX(T &v){return *max_element(v.begin(),v.end());}
template <typename T> auto inline MIN(T &v){return *min_element(v.begin(),v.end());}
template <typename T> auto inline SUM(vector<T> &v){T ans = 0; for(int i = 0; i < (int)v.size(); i++)ans += v[i]; return ans;}
template <typename T> void inline DEC(T &v){for(int i = 0; i < (int)v.size(); i++)v[i]--; return;}
template <typename T> void inline INC(T &v){for(int i = 0; i < (int)v.size(); i++)v[i]++; return;}
void inline TEST(void){cerr << "TEST" << endl; return;}
template <typename T,typename S> bool inline chmin(T &x,S y){
if(x > (T)y){
x = (T)y;
return true;
}
return false;
}
template <typename T,typename S> bool inline chmax(T &x,S y){
if(x < (T)y){
x = (T)y;
return true;
}
return false;
}
template <typename T = long long> vector<T> inline get_vec(int n){
vector<T> ans(n);
for(int i = 0; i < n; i++)cin >> ans[i];
return ans;
}
template <typename T> void inline print_vec(vector<T> &vec,bool kaigyou = false){
int n = (int)vec.size();
for(int i = 0; i < n; i++){
cout << vec[i];
if(kaigyou || i == n - 1)cout << '\n';
else cout << ' ';
}
if(!n)cout << '\n';
return;
}
template <typename T> void inline debug_vec(vector<T> &vec,bool kaigyou = false){
int n = (int)vec.size();
for(int i = 0; i < n; i++){
cerr << vec[i];
if(kaigyou || i == n - 1)cerr << '\n';
else cerr << ' ';
}
if(!n)cerr << '\n';
return;
}
vector<vector<int>> inline get_graph(int n,int m = -1,bool direct = false,bool decrement = true){
if(m == -1)m = n - 1;
vector<vector<int>> g(n);
while(m--){
int u,v;
cin >> u >> v;
if(decrement)u--,v--;
g[u].push_back(v);
if(!direct)g[v].push_back(u);
}
return g;
}
template <typename T> vector<vector<pair<T,int>>> inline get_weighted_graph(int n,int m = -1,bool direct = false,bool decrement = true){
if(m == -1)m = n - 1;
vector<vector<pair<T,int>>> g(n);
while(m--){
int u,v;
cin >> u >> v;
if(decrement)u--,v--;
ll w; cin >> w;
g[u].push_back(pair(w,v));
if(!direct)g[v].push_back(pair(w,u));
}
return g;
}
#define MULTI_TEST_CASE true
void solve(void){
//問題を見たらまず「この問題設定から言えること」をいっぱい言う
//よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書く
//複数の解法のアイデアを思いついた時は全部メモしておく
//g++ -D_GLIBCXX_DEBUG -Wall -O2 f.cpp -o o
//h,w のどっちかが偶数なら
//11111
//00000
//11111
//00000 みたいにすればいい
int h,w;
cin >> h >> w;
if(h == 3 && w == 3)EXIT_ANS(NO);
if(h % 2 == 0){
cout << YES << el;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
cout << (i % 2);
}
cout << el;
}
return;
}
if(w % 2 == 0){
cout << YES << el;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
cout << (j % 2);
}
cout << el;
}
return;
}
//012
//345
//678
//↑こういう風に番号を振った時、どの 3*3 についても 0 と3, 5と7 の値が違うと強い
bool same = false;
if(h == w){
same = true;
h -= 2;
}
vector<vector<int>> ans(h,vector<int>(w));
if(h != w){
cout << YES << el;
int val = 1;
int x = 0,y = 0;
int t = h * w;
while(t--){
ans[x][y] = val % 2;
val++;
x++; if(x >= h)x -= h;
y--; if(y < 0)y += w;
}
}
if(same){
ans.push_back(ans[0]);
ans.push_back(ans[1]);
h += 2;
}
for(int i = 0; i < h ; i++){
for(int j = 0; j < w; j++)cout << ans[i][j];
cout << el;
}
return;
}
void calc(void){
vector<int> dx = {0,0,1,0,-1};
vector<int> dy = {0,1,0,-1,0};
for(int h = 3; h <= 7; h += 2){
for(int w = h; w <= 7; w += 2){
if(h * w > 25)continue;
cerr << h << ' ' << w << el;
int bunsi = 0,bunbo = 0;
for(int S = 0; S < (1 << (h * w)); S++){
//if(__popcount(S) != (h * w) / 2)continue;
bunbo++;
bool ng = false;
vector<vector<int>> v(h,vector<int>(w));
int idx = 0;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
if(S & (1 << idx))v[i][j] = 1;
idx++;
}
}
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
int cnt = 0;
for(int l = 0; l < 5; l++){
int x = (i + dx[l] + h) % h;
int y = (j + dy[l] + w) % w;
cnt += v[x][y];
}
if(cnt <= 1 || cnt >= 4)ng = true;
}
}
if(!ng){
bunsi++;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++)cout << v[i][j];
cout << el;
}
cout << el;
}
}
cerr << bunsi << ' ' << bunbo << el;
}
}
return;
}
signed main(void){
cin.tie(nullptr);
ios::sync_with_stdio(false);
//calc(); return 0;
int t = 1;
if(MULTI_TEST_CASE)cin >> t;
while(t--){
solve();
}
return 0;
}
ococonomy1