結果
問題 |
No.466 ジオラマ
|
ユーザー |
![]() |
提出日時 | 2025-06-28 16:54:47 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 2,174 bytes |
コンパイル時間 | 5,012 ms |
コンパイル使用メモリ | 214,908 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-28 16:54:57 |
合計ジャッジ時間 | 9,020 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 83 |
ソースコード
#include<bits/stdc++.h> using namespace std; const int N=1e5+5; void FileIO(){ freopen("hometown.in","r",stdin); freopen("hometown.out","w",stdout); } namespace sunburstfan{ #define int long long #define pii pair<int,int> int a,b,c,d,n,m; vector<pii > e; void solve(){ cin>>a>>b>>c>>d; if(a==b&&b==c){ if(a==1){ cout<<-1<<"\n"; return; } e.push_back({0,1}); e.push_back({1,0}); for(int i=2;i<=a-1;i++){ e.push_back({i-1,i}); } } else if(a==c){ e.push_back({1,0}); n=1; for(int i=1;i<=a-1;i++){ e.push_back({0,++n}); } b-=a; for(int i=1;i<=b-1;i++){ e.push_back({1,++n}); } } else if(b==c){ e.push_back({0,1}); n=1; for(int i=1;i<=b-1;i++){ e.push_back({1,++n}); } a-=b; for(int i=1;i<=a-1;i++){ e.push_back({0,++n}); } } else{ int lst=0,p=0; n=1; for(int i=1;i<=a-1;i++){ e.push_back({lst,++n}); lst=n; if(a-c+1==i+1)p=lst; } lst=1; for(int i=1;i<=b-c-1;i++){ e.push_back({lst,++n}); lst=n; } if(c)e.push_back({lst,p}); } m=e.size(); if(m>d){ cout<<-1<<"\n"; return; } n=1; for(int i=0;i<m;i++){ n=max(n,e[i].first); n=max(n,e[i].second); } cout<<n+1<<" "<<m<<"\n"; for(int i=0;i<m;i++){ cout<<e[i].first<<" "<<e[i].second<<"\n"; } return; } } using namespace sunburstfan; #undef int int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); //FileIO(); int T=1; while(T--){ solve(); } return 0; }