結果
| 問題 | No.466 ジオラマ |
| コンテスト | |
| ユーザー |
tubo28
|
| 提出日時 | 2016-12-16 03:20:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,230 bytes |
| 記録 | |
| コンパイル時間 | 1,798 ms |
| コンパイル使用メモリ | 175,216 KB |
| 実行使用メモリ | 19,308 KB |
| 最終ジャッジ日時 | 2024-11-30 10:07:53 |
| 合計ジャッジ時間 | 25,508 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 5 WA * 8 RE * 70 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl
int g[2010][2010];
bool solve(int a, int b, int c, int m){
int n = a + b + c;
rep(i, n) rep(j, n) g[i][j] = false;
int k = 2;
vector<int> as, bs, cs;
rep(i, a - 1) as.push_back(k++);
rep(i, b - 1) bs.push_back(k++);
if(!c){
if(!a || !b) return false;
as.push_back(0);
bs.push_back(1);
} else {
if(a) as.push_back(0); else cs.push_back(0);
if(b) bs.push_back(1); else cs.push_back(1);
rep(i, c - !a - !b) cs.push_back(k++);
}
sort(all(as));
sort(all(bs));
sort(all(cs));
dump(a);
dump(b);
dump(c);
// for(auto &e : as) cout << e << ' ';
// cout << endl;
// for(auto &e : bs) cout << e << ' ';
// cout << endl;
// for(auto &e : cs) cout << e << ' ';
// cout << endl;
// assert(k == n);
rep(i, a - 1) g[as[i]][as[i+1]] = true, --m;
rep(i, b - 1) g[bs[i]][bs[i+1]] = true, --m;
rep(i, c - 1) g[cs[i]][cs[i+1]] = true, --m;
if(a && c) g[as[0]][cs[0]] = true, --m;
if(b && c) g[bs[0]][cs[0]] = true, --m;
if(m < 0) return false;
// auto fill_v = [&](const vector<int> &vs){
// rep(i, vs.size()) rep(j, i){
// if(m && !g[vs[i]][vs[j]]) g[vs[i]][vs[j]] = true, --m;
// }
// };
// auto fill_vw = [&](const vector<int> &vs, const vector<int> &ws){
// rep(i, vs.size()) rep(j, ws.size()){
// if(m && !g[vs[i]][ws[j]]) g[vs[i]][ws[j]] = true, --m;
// }
// };
// fill_v(as);
// fill_v(bs);
// fill_v(cs);
// fill_vw(as, cs);
// fill_vw(bs, cs);
return true;
}
int main(){
int A, B, C, D;
while(cin >> A >> B >> C >> D){
int a = A - C;
int b = B - C;
if(solve(a, b, C, D)){
int n = a + b + C;
int m = 0;
rep(i,n) rep(j,n) if(g[i][j]) ++m;
cout << n << ' ' << m << '\n';
rep(i,n) rep(j,n) if(g[i][j]) cout << i << ' ' << j << '\n';
} else puts("-1");
}
}
tubo28