結果
問題 | No.2112 All 2x2 are Equal |
ユーザー | otoshigo |
提出日時 | 2022-10-28 22:25:28 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 1,938 bytes |
コンパイル時間 | 3,666 ms |
コンパイル使用メモリ | 203,388 KB |
実行使用メモリ | 7,028 KB |
最終ジャッジ日時 | 2023-09-20 05:29:29 |
合計ジャッジ時間 | 9,595 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 4 ms
4,380 KB |
testcase_03 | AC | 4 ms
4,380 KB |
testcase_04 | AC | 32 ms
4,544 KB |
testcase_05 | AC | 42 ms
5,176 KB |
testcase_06 | AC | 72 ms
6,664 KB |
testcase_07 | AC | 23 ms
4,376 KB |
testcase_08 | AC | 59 ms
5,968 KB |
testcase_09 | AC | 5 ms
4,380 KB |
testcase_10 | AC | 27 ms
4,380 KB |
testcase_11 | AC | 20 ms
4,376 KB |
testcase_12 | AC | 22 ms
4,380 KB |
testcase_13 | AC | 65 ms
6,240 KB |
testcase_14 | AC | 4 ms
4,376 KB |
testcase_15 | AC | 47 ms
5,436 KB |
testcase_16 | AC | 2 ms
4,376 KB |
testcase_17 | AC | 58 ms
5,976 KB |
testcase_18 | AC | 3 ms
4,380 KB |
testcase_19 | AC | 6 ms
4,380 KB |
testcase_20 | AC | 3 ms
4,376 KB |
testcase_21 | AC | 56 ms
5,864 KB |
testcase_22 | AC | 5 ms
4,376 KB |
testcase_23 | AC | 4 ms
4,376 KB |
testcase_24 | AC | 8 ms
4,376 KB |
testcase_25 | AC | 10 ms
4,376 KB |
testcase_26 | AC | 8 ms
4,380 KB |
testcase_27 | AC | 15 ms
4,376 KB |
testcase_28 | AC | 34 ms
4,808 KB |
testcase_29 | AC | 6 ms
4,384 KB |
testcase_30 | AC | 23 ms
4,380 KB |
testcase_31 | AC | 44 ms
5,180 KB |
testcase_32 | AC | 79 ms
7,028 KB |
testcase_33 | AC | 78 ms
7,024 KB |
testcase_34 | AC | 77 ms
6,976 KB |
testcase_35 | AC | 77 ms
7,028 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i<n;i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int h,w; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); cin>>h>>w; vector<vector<int>>S(h,vector<int>(w)); if(w%2==0){ int x=1; rep(i,h){ if(i%2==0){ for(int j=0;j<w;j+=2){ S[i][j]=x++; } }else{ for(int j=w-2;j>=0;j-=2){ S[i][j]=x++; } } } rrep(i,h){ if(i%2!=(h-1)%2){ for(int j=1;j<w;j+=2){ S[i][j]=x++; } }else{ for(int j=w-1;j>=1;j-=2){ S[i][j]=x++; } } } }else{ int x=1; rep(i,h){ if(i%2==0){ for(int j=0;j<w;j+=2){ S[i][j]=x; x+=2; } }else{ for(int j=w-1;j>=0;j-=2){ S[i][j]=x; x+=2; } } x--; } x=2; rrep(i,h){ if(i%2!=(h-1)%2){ for(int j=1;j<w-1;j+=2){ S[i][j]=x; x+=2; } }else{ for(int j=w-2;j>=1;j-=2){ S[i][j]=x; x+=2; } } x++; } } cout<<"Yes"<<"\n"; rep(i,h){ rep(j,w)cout<<S[i][j]<<" "; cout<<"\n"; } }