結果
| 問題 |
No.1384 Bishop and Rook
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-07 22:53:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 135 ms / 2,000 ms |
| コード長 | 1,701 bytes |
| コンパイル時間 | 759 ms |
| コンパイル使用メモリ | 82,284 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 17:17:34 |
| 合計ジャッジ時間 | 6,284 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 55 |
ソースコード
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
#define int long long
#define endl "\n"
constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007;
struct fast_io {
fast_io(){
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
};
} fio;
int dy[] = {0, 0, 1, 1};
int dx[] = {0, 1, 0, 1};
#define x first
#define y second
void print(int ny, int nx, vector<int> v){
// cout<<" <><><> "<<" "<<ny<<" "<<nx<<endl;
for(int i = 0; i < v.size(); i++){
cout<<ny+dy[v[i]]+1<<" "<<nx+dx[v[i]]+1<<endl;
// cout<<dy[v[i]]<<" "<<dx[v[i]]<<" "<<v[i]<<endl;
}
}
signed main(){
cout<<fixed<<setprecision(10);
int T;
cin>>T;
for(int _ = 0; _ < T; _++){
int N, M;
cin>>N>>M;
if(N%2 || M%2) {
if(N == 1 && M == 1) {
cout<<0<<endl;
cout<<1<<" "<<1<<endl;
} else {
cout<<-1<<endl;
}
} else {
cout<<N * M -1<<endl;
// cout<<2<<" "<<1<<endl;
for(int i = 0; i < M; i += 4){
print(0, i, {2, 1, 0, 3});
for(int j = 2; j < N; j += 2){
print(j, i, {1, 2, 0, 3});
}
if(i + 2 >= M) break;
for(int j = N-2; j >= 2; j -= 2){
print(j, i+2, {2, 1, 3, 0});
}
print(0, i+2, {2, 1, 0, 3});
}
}
}
return 0;
}