結果
| 問題 |
No.466 ジオラマ
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-06-20 16:49:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 2,855 bytes |
| コンパイル時間 | 2,027 ms |
| コンパイル使用メモリ | 212,452 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 16:49:26 |
| 合計ジャッジ時間 | 6,564 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 83 |
ソースコード
#include<bits/stdc++.h>
#define int long long
#define all(v)v.begin(),v.end()
#define rall(v)v.rbegin(),v.rend()
bool st;
using namespace std;
template<typename T>istream&operator>>(istream&I,vector<T>&v){for(auto&i:v)I>>i;return I;}
template<typename T>ostream&operator<<(ostream&O,vector<T> v){for(auto i:v)O<<i<<' ';return O;}
string TMP,STR;
stringstream CIN;
void read_all(){
#ifdef debug
cerr<<"----------------------------------- START -----------------------------------\n";
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
while(getline(cin,TMP))STR+=TMP,STR+='\n';
CIN.str(STR);
cerr<<"\n--------------------------------- INPUT END ---------------------------------\n";
#endif
}
#ifdef debug
#define cin CIN
#endif
namespace AC{
void solve(){
int a,b,c,d;
cin>>a>>b>>c>>d;
bool bl=0;
vector<pair<int,int>>e;
if(a==c&&b==c){
if(c==1)bl=true;
for(int i=0;i<c;i++)e.push_back({i,(i+1)%c});
}
else{
int A=1000000;
int B=2000000;
int C=3000000;
map<int,int>tr;
if(c==0){
for(int i=0;i<a-1;i++)e.push_back({A+i,A+i+1});
for(int i=0;i<b-1;i++)e.push_back({B+i,B+i+1});
}
else{
for(int i=0;i<a-c;i++)e.push_back({A+i,A+i+1});
for(int i=0;i<b-c;i++)e.push_back({B+i,B+i+1});
for(int i=0;i<c-1;i++)e.push_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>mp;
mp[A]=0;
mp[B]=1;
auto get=[&](int&i){
if(tr.count(i))i=tr[i];
if(!mp.count(i)){
int size=mp.size();
mp[i]=size;
}
i=mp[i];
};
for(auto&it:e){
get(it.first);
get(it.second);
}
}
if(bl||e.size()>d){
cout<<-1<<endl;
}
else{
cout<<a+b-c<<' '<<e.size()<<endl;
for(auto it:e)cout<<it.first<<' '<<it.second<<endl;
}
}
}
bool ed;
signed main(){
chrono::steady_clock::time_point St=chrono::steady_clock::now();
read_all();
chrono::steady_clock::time_point ST=chrono::steady_clock::now();
int t=1;
//cin>>t;
while(t--)AC::solve();
chrono::steady_clock::time_point ED=chrono::steady_clock::now();
cerr<<setprecision(3)<<fixed<<"\n\n------------------------------------ END ------------------------------------\n"<<"Total Time : "<<left<<setw(10)<<chrono::duration_cast<chrono::milliseconds>(ED-St).count()<<" \tms\n"<<"Real Time : "<<left<<setw(10)<<chrono::duration_cast<chrono::milliseconds>(ED-ST).count()<<" \tms\n"<<" : "<<left<<setw(10)<<chrono::duration_cast<chrono::microseconds>(ED-ST).count()<<" \t?s\n\n"<<"Total Memory : "<<left<<setw(10)<<(&ed-&st)/1048576.0<<" \tMB\n"<<" "<<left<<setw(10)<<(&ed-&st)/1024.0<<" \tKB\n"<<" "<<left<<setw(10)<<(&ed-&st)<<" \tByte\n";
}
vjudge1