結果
問題 | No.466 ジオラマ |
ユーザー |
|
提出日時 | 2016-12-16 23:34:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 38 ms / 2,000 ms |
コード長 | 1,533 bytes |
コンパイル時間 | 962 ms |
コンパイル使用メモリ | 88,556 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 21:53:01 |
合計ジャッジ時間 | 5,018 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 83 |
ソースコード
#include <iostream>#include <vector>#include <map>#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))using namespace std;int main() {int a, b, c, d; cin >> a >> b >> c >> d;bool impossible = false;vector<pair<int, int> > e;if (a == c and b == c) {if (c == 1) impossible = true;repeat (i,c) e.emplace_back(i, (i+1)%c);} else {int A = 1000000;int B = 2000000;int C = 3000000;map<int,int> tr;if (c == 0) {repeat (i,a-1) e.emplace_back(A+i, A+i+1);repeat (i,b-1) e.emplace_back(B+i, B+i+1);} else {repeat (i,a-c) e.emplace_back(A+i, A+i+1);repeat (i,b-c) e.emplace_back(B+i, B+i+1);repeat (i,c-1) e.emplace_back(C+i, C+i+1);if (a == c) A = C;if (b == c) B = C;tr[A+a-c] = C;tr[B+b-c] = C;}map<int,int> compress;compress[A] = 0;compress[B] = 1;auto name = [&](int & i) {if (tr.count(i)) i = tr[i];if (not compress.count(i)) { int size = compress.size(); compress[i] = size; }i = compress[i];};for (auto & it : e) {name(it.first);name(it.second);}}if (impossible or e.size() > d) {cout << -1 << endl;} else {cout << a+b-c << ' ' << e.size() << endl;for (auto it : e) cout << it.first << ' ' << it.second << endl;}return 0;}