結果

問題 No.466 ジオラマ
ユーザー mamekinmamekin
提出日時 2017-06-11 17:46:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,775 bytes
コンパイル時間 936 ms
コンパイル使用メモリ 108,348 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-24 16:23:53
合計ジャッジ時間 4,830 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 83
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
bool solve(int a, int b, int c, int d, vector<pair<int, int> >& ans)
{
if(a == c && b == c){
if(c == 1)
return false;
ans.push_back(make_pair(1, 0));
for(int i=1; i<c; ++i)
ans.push_back(make_pair(i-1, i));
return true;
}
if(a > b){
solve(b, a, c, d, ans);
for(auto& p : ans){
if(p.first < 2)
p.first ^= 1;
if(p.second < 2)
p.second ^= 1;
}
return true;
}
vector<int> x(a);
x[0] = 0;
for(int i=1; i<a; ++i){
x[i] = i + 1;
ans.push_back(make_pair(x[i-1], x[i]));
}
vector<int> y(b-c);
y[0] = 1;
for(int i=1; i<b-c; ++i){
y[i] = a+i;
ans.push_back(make_pair(y[i-1], y[i]));
}
if(c > 0)
ans.push_back(make_pair(y.back(), x[a-c]));
return true;
}
int main()
{
int a, b, c, d;
cin >> a >> b >> c >> d;
vector<pair<int, int> > ans;
if(!solve(a, b, c, d, ans)){
cout << -1 << endl;
return 0;
}
int n = a + b - c;
int m = ans.size();
if(m > d){
cout << -1 << endl;
return 0;
}
cout << n << ' ' << m << endl;
for(int i=0; i<m; ++i)
cout << ans[i].first << ' ' << ans[i].second << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0