結果
問題 | No.2112 All 2x2 are Equal |
ユーザー |
|
提出日時 | 2022-10-28 22:24:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,915 bytes |
コンパイル時間 | 1,922 ms |
コンパイル使用メモリ | 197,896 KB |
最終ジャッジ日時 | 2025-02-08 14:42:09 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | WA * 34 |
ソースコード
#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++; } } rep(i,h){ rep(j,w)cout<<S[i][j]<<" "; cout<<"\n"; } }