답안 #62976

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
62976 2018-07-31T04:20:21 Z qkxwsm 항공 노선도 (JOI18_airline) C++17
0 / 100
648 ms 38680 KB
#include "Alicelib.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

struct chash
{
        int operator()(int x) const
        {
                x ^= (x >> 20) ^ (x >> 12);
                return x ^ (x >> 7) ^ (x >> 4);
        }
        int operator()(long long x) const
        {
                return x ^ (x >> 32);
        }
};

template<typename T> using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename U> using hashtable = gp_hash_table<T, U, chash>;

template<class T>
void readi(T &x)
{
        T input = 0;
        bool negative = false;
        char c = ' ';
        while (c < '-')
        {
                c = getchar();
        }
        if (c == '-')
        {
                negative = true;
                c = getchar();
        }
        while (c >= '0')
        {
                input = input * 10 + (c - '0');
                c = getchar();
        }
        if (negative)
        {
                input = -input;
        }
        x = input;
}
template<class T>
void printi(T output)
{
        if (output == 0)
        {
                putchar('0');
                return;
        }
        if (output < 0)
        {
                putchar('-');
                output = -output;
        }
        int aout[20];
        int ilen = 0;
        while(output)
        {
                aout[ilen] = ((output % 10));
                output /= 10;
                ilen++;
        }
        for (int i = ilen - 1; i >= 0; i--)
        {
                putchar(aout[i] + '0');
        }
        return;
}
template<class T>
void ckmin(T &a, T b)
{
        a = min(a, b);
}
template<class T>
void ckmax(T &a, T b)
{
        a = max(a, b);
}
template<class T>
T normalize(T x, T mod = 1000000007)
{
        return (((x % mod) + mod) % mod);
}
static long long randomizell(long long mod)
{
        return ((1ll << 45) * rand() + (1ll << 30) * rand() + (1ll << 15) * rand() + rand()) % mod;
}
static int randomize(int mod)
{
        return ((1ll << 15) * rand() + rand()) % mod;
}

#define y0 ___y0
#define y1 ___y1
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define debug(x) cerr << #x << " = " << x << endl;

const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-10;

#define MAGIC 347
#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

int N;
vector<pii> EDGE, EDGES;

void send()
{
	InitG(N + 12, EDGES.size());
	for (int i = 0; i < EDGES.size(); i++)
	{
		assert(EDGES[i].fi != EDGES[i].se);
		MakeG(i, EDGES[i].fi, EDGES[i].se);
	}
	return;
}
void Alice(int n, int m, int a[], int b[])
{
	N = n;
	for (int i = 0; i < m; i++)
	{
		assert(0 <= a[i] && a[i] < N);
		assert(0 <= b[i] && b[i] < N);
		assert(a[i] != b[i]);
		if (a[i] > b[i])
		{
			swap(a[i], b[i]);
		}
		EDGE.PB(MP(a[i], b[i]));
	}
	assert(N != 0);
	for (int i = 0; i < EDGE.size(); i++)
	{
		int u = EDGE[i].fi, v = EDGE[i].se;
		EDGES.PB(MP(u, v));
	}
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			if (i & (1 << j))
			{
				EDGES.PB(MP(i, N + j));
			}
		}
	}
	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < i; j++)
		{
			EDGES.PB(MP(N + j, N + i));
		}
	}
	for (int i = 0; i < N + 10; i++)
	{
		EDGES.PB(MP(i, N + 10));
	}
	//N + 10 is friends with everybody but N+11
	//N+11 is friends with all the guys in the loop
	for (int i = N; i < N + 10; i++)
	{
		EDGES.PB(MP(i, N + 11));
	}
	send();
	return;
}
#include "Boblib.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

struct chash
{
        int operator()(int x) const
        {
                x ^= (x >> 20) ^ (x >> 12);
                return x ^ (x >> 7) ^ (x >> 4);
        }
        int operator()(long long x) const
        {
                return x ^ (x >> 32);
        }
};

template<typename T> using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename U> using hashtable = gp_hash_table<T, U, chash>;

template<class T>
void readi(T &x)
{
	T input = 0;
	bool negative = false;
	char c = ' ';
	while (c < '-')
        {
		c = getchar();
	}
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = input * 10 + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	x = input;
}
template<class T>
void printi(T output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
template<class T>
void ckmin(T &a, T b)
{
	a = min(a, b);
}
template<class T>
void ckmax(T &a, T b)
{
	a = max(a, b);
}
template<class T>
T normalize(T x, T mod = 1000000007)
{
	return (((x % mod) + mod) % mod);
}
 long long randomizell(long long mod)
{
	return ((1ll << 45) * rand() + (1ll << 30) * rand() + (1ll << 15) * rand() + rand()) % mod;
}
 int randomize(int mod)
{
	return ((1ll << 15) * rand() + rand()) % mod;
}

#define y0 ___y0
#define y1 ___y1
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define debug(x) cerr << #x << " = " << x << endl;

const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-10;

#define MAGIC 347
#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
#define MAXN 1313

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

int V;
vector<pii> edges, isbits;
vector<int> edge[MAXN];
int bt[MAXN], id[MAXN];
bool isbit[MAXN], inlone[MAXN];
int lone, control;

void finish()
{
	InitMap(V - 12, edges.size());
	for (pii x : edges)
	{
		assert(x.fi != x.se);
		MakeMap(x.fi, x.se);
	}
	return;
}
void Bob(int n, int m, int a[], int b[])
{
	V = n;
	for (int i = 0; i < m; i++)
	{
		edge[b[i]].PB(a[i]);
	}
	int freq = 0;
	for (int i = 0; i < V; i++)
	{
		if (edge[i].size() == V - 2)
		{
			lone = i;
			freq++;
		}
	}
	for (int x : edge[lone])
	{
		inlone[x] = true;
	}
	for (int i = 0; i < V; i++)
	{
		if (i != lone && !inlone[i])
		{
			control = i;
		}
	}
	for (int x : edge[control])
	{
		isbits.PB(MP(x, 0));
		isbit[x] = true;
	}
	for (pii &p : isbits)
	{
		int u = p.fi;
		for (int v : edge[u])
		{
			if (isbit[v])
			{
				p.se++;
			}
		}
		bt[p.se]= u;
	}
	for (int i = 0; i < 10; i++)
	{
		int u = bt[i];
		for (int v : edge[u])
		{
			if (isbit[v] || v == control ||  v == lone)
			{
				continue;
			}
			id[v] += (1 << i);
		}
	}
	for (int u = 0; u < V; u++)
	{
		if (isbit[u] || u == control || u == lone)
		{
			continue;
		}
		for (int v : edge[u])
		{
			if (isbit[v] || v == control || v == lone)
			{
				continue;
			}
			edges.PB(MP(id[u], id[v]));
		}
	}
	finish();
}

Compilation message

Alice.cpp: In function 'void send()':
Alice.cpp:138:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < EDGES.size(); i++)
                  ~~^~~~~~~~~~~~~~
Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:160:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < EDGE.size(); i++)
                  ~~^~~~~~~~~~~~~
Alice.cpp: At global scope:
Alice.cpp:97:12: warning: 'int randomize(int)' defined but not used [-Wunused-function]
 static int randomize(int mod)
            ^~~~~~~~~
Alice.cpp:93:18: warning: 'long long int randomizell(long long int)' defined but not used [-Wunused-function]
 static long long randomizell(long long mod)
                  ^~~~~~~~~~~

Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:160:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (edge[i].size() == V - 2)
       ~~~~~~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 6640 KB Wrong Answer [11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 6640 KB Wrong Answer [11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 648 ms 38680 KB Wrong Answer [11]
2 Halted 0 ms 0 KB -