結果

問題 No.466 ジオラマ
ユーザー chaemonchaemon
提出日時 2016-12-16 00:46:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 4,201 bytes
コンパイル時間 1,145 ms
コンパイル使用メモリ 106,780 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-07 15:33:39
合計ジャッジ時間 15,205 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
5,376 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 2 ms
5,376 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 2 ms
5,376 KB
testcase_38 RE -
testcase_39 AC 2 ms
5,376 KB
testcase_40 RE -
testcase_41 AC 2 ms
5,376 KB
testcase_42 RE -
testcase_43 AC 1 ms
5,376 KB
testcase_44 RE -
testcase_45 AC 3 ms
5,376 KB
testcase_46 RE -
testcase_47 AC 2 ms
5,376 KB
testcase_48 RE -
testcase_49 AC 2 ms
5,376 KB
testcase_50 RE -
testcase_51 AC 2 ms
5,376 KB
testcase_52 RE -
testcase_53 AC 2 ms
5,376 KB
testcase_54 RE -
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 4 ms
5,376 KB
testcase_57 AC 1 ms
5,376 KB
testcase_58 AC 3 ms
5,376 KB
testcase_59 AC 1 ms
5,376 KB
testcase_60 AC 6 ms
5,376 KB
testcase_61 AC 2 ms
5,376 KB
testcase_62 AC 4 ms
5,376 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 4 ms
5,376 KB
testcase_65 AC 1 ms
5,376 KB
testcase_66 RE -
testcase_67 AC 2 ms
5,376 KB
testcase_68 RE -
testcase_69 AC 2 ms
5,376 KB
testcase_70 RE -
testcase_71 AC 1 ms
5,376 KB
testcase_72 RE -
testcase_73 AC 2 ms
5,376 KB
testcase_74 RE -
testcase_75 AC 2 ms
5,376 KB
testcase_76 AC 2 ms
5,376 KB
testcase_77 AC 2 ms
5,376 KB
testcase_78 AC 2 ms
5,376 KB
testcase_79 AC 2 ms
5,376 KB
testcase_80 AC 2 ms
5,376 KB
testcase_81 RE -
testcase_82 WA -
testcase_83 RE -
testcase_84 AC 16 ms
5,376 KB
testcase_85 RE -
testcase_86 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'bool check(int, const std::vector<std::pair<int, int> >&)':
main.cpp:122:1: warning: control reaches end of non-void function [-Wreturn-type]
  122 | }
      | ^

ソースコード

diff #

// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int vis[100100];

//{{{ Graph
typedef int Weight;
struct Edge {
	int src, dst, rev;
	Weight weight;
	Edge(int src, int dst, Weight weight=1,int rev=-1) :
		src(src), dst(dst), weight(weight), rev(rev) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
		e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

//add bi-directional edge
void addBiEdge(Graph &g,int from ,int to, Weight w=1){
	while(g.size()<max(from,to)+1)g.push_back(Edges());
	g[from].push_back(Edge(from,to,w,g[to].size()));
	g[to].push_back(Edge(to,from,w,g[from].size()-1));
}
//add directional edge
void addEdge(Graph &g,int from ,int to, Weight w=1){
	while(g.size()<from+1)g.push_back(Edges());
	g[from].push_back(Edge(from,to,w));
}
#ifdef DEBUG
#include"graph/graphviz.h"
#endif
//}}}

Graph g;

void dfs(int u,int b){
	if(vis[u]&b)return;
	vis[u]|=b;
	FOR(e,g[u]){
		dfs(e->dst,b);
	}
}

int A,B,C,D;

bool check(int N,const vector<pii> &e){
	g.assign(N,Edges());
	REP(i,e.size())g[e[i].first].push_back(Edge(e[i].first,e[i].second));
	memset(vis,0,sizeof(vis));
	dfs(0,1);
	dfs(1,2);
	int A0=0,B0=0,C0=0;
	REP(u,N){
		if(vis[u]&1)A0++;
		if(vis[u]&2)B0++;
		if(vis[u]==3)C0++;
	}
	assert(A0==A and B0==B and C0==C);
}

int N;

int main(){
	vector<int> a,b,c;
	cin>>A>>B>>C>>D;
	if(A==C and B==C){
		if(D<A){
			cout<<-1<<endl;
		}else{
			cout<<A<<" "<<A<<endl;
			REP(i,A){
				cout<<i<<" "<<(i+1)%A<<endl;
			}
		}
		return 0;
	}else if(A==C){
		c.push_back(0);
		int t = 2;
		REP(i,C-1)c.push_back(t++);
		b.push_back(1);
		REP(j,B-C-1)b.push_back(t++);
	}else if(B==C){
		c.push_back(1);
		int t = 2;
		REP(i,C-1)c.push_back(t++);
		a.push_back(0);
		REP(j,A-C-1)a.push_back(t++);
	}else{
		int t = 2;
		a.push_back(0);
		REP(i,A-C-1){
			a.push_back(t++);
		}
		b.push_back(1);
		REP(j,B-C-1){
			b.push_back(t++);
		}
		REP(k,C){
			c.push_back(t++);
		}
	}
	N = (int)a.size()+(int)b.size()+(int)c.size()+5;
	vector<pii> e;
	REP(i,a.size()){
		if(i+1<a.size())e.push_back(make_pair(a[i],a[i+1]));
	}
	REP(i,b.size()){
		if(i+1<b.size())e.push_back(make_pair(b[i],b[i+1]));
	}
	if(a.size()>0 and c.size()>0)e.push_back(make_pair(a.back(),c.front()));
	if(b.size()>0 and c.size()>0)e.push_back(make_pair(b.back(),c.front()));
	REP(i,c.size()){
		if(i+1<c.size())e.push_back(make_pair(c[i],c[i+1]));
	}
	if(D<e.size()){
//	if(false){
		cout<<-1<<endl;
	}else{
		cout<<N<<" "<<e.size()<<endl;
		REP(i,e.size()){
			cout<<e[i].first<<" "<<e[i].second<<endl;
			assert(0<=e[i].first and e[i].first<N and 0<=e[i].second and e[i].second<N);
		}
		check(N,e);
	}
	return 0;
}
0