답안 #1072290

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072290 2024-08-23T16:29:55 Z abczz 항공 노선도 (JOI18_airline) C++17
37 / 100
357 ms 33520 KB
#include "Alicelib.h"
#include <cassert>
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#define ll long long
 
using namespace std;
 
void Alice( int N, int M, int A[], int B[] ){
	vector <array<ll, 2>> V;
	ll k = N, tot = 0, cnt = N;
	while (k) {
		k /= 2;
		++tot;
	}
	for (int i=0; i<M; ++i) {
		V.push_back({A[i], B[i]});
	}
	k = 1;
	if (tot != 10) {
    V.push_back({cnt, cnt+1});
	  ++cnt;
  }
	for (int i=0; i<tot; ++i) {
		for (int j=0; j<N; ++j) {
			if ((j+1) & k) V.push_back({cnt, j});
		}
		if (i != tot-1) V.push_back({cnt, cnt+1});
		++cnt, k *= 2;
	}
	for (int i=0; i<cnt; ++i) {
		V.push_back({i, cnt});
	}
	if (N < 10) {
		for (int i=1; i<5; ++i) {
			++cnt;
			V.push_back({cnt-i, cnt});
		}
	}
	++cnt;
	for (int j=N; j<N+tot+(tot != 10 ? 1 : 0); ++j) {
		V.push_back({j, cnt});
	}
	++cnt;
	InitG(cnt, V.size());
	int i = 0;
	for (auto [a, b] : V) {
		//cout << a << " " << b << endl;
		MakeG(i++, a, b);
	}
}
#include "Boblib.h"
#include <cassert>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#define ll long long
 
using namespace std;
 
ll in[2000], F[2000];
bool B[2000], G[2000];
vector <ll> adj[2000];
vector <array<ll, 2> > V, X;
ll n, x, z, rt = 0;
 
void dfs(ll u, ll p, ll k) {
	for (auto v : adj[u]) {
		if (!G[v] && v != rt && v != z) {
			F[v] += k;
		}
	}
	for (auto v : adj[u]) {
		if (G[v] && v != p) dfs(v, u, (!k ? 1 : k*2));
	}
}
void Bob( int Z, int U, int C[], int D[] ){
	n = Z;
	V.clear();
	X.clear();
	for (int i=0; i<n; ++i) in[i] = B[i] = F[i] = G[i] = 0, adj[i].clear();
	for (int i=0; i<U; ++i) {
		++in[C[i]], ++in[D[i]];
		adj[C[i]].push_back(D[i]);
		adj[D[i]].push_back(C[i]);
	}
	x = 0;
	for (int i=0; i<n; ++i) {
		if (in[i] == 1) --x;
		if (in[i] == n-2) {
			rt = i;
		}
	}
	B[rt] = 1;
	for (auto v : adj[rt]) {
		B[v] = 1;
	}
	z = rt;
	for (int i=0; i<n; ++i) {
		if (!B[i]) {
			rt = i;
			break;
		}
	}
	x += Z-2-adj[rt].size();
	for (auto v : adj[rt]) {
		in[v] -= 2;
		//cout << v << " " << in[v] << endl;
		G[v] = 1;
	}
  bool ok = 0;
	for (auto v : adj[rt]) {
		if (in[v] == 1) {
      ok = 1;
			dfs(v, -1, 0);
			break;
		}
	}
  if (!ok) {
    ll mx = -1, id = -1, deg;
    for (auto v : adj[rt]) {
      deg = 0;
      for (auto x : adj[x]) {
        if (G[x]) ++deg;
      }
      if (deg == 1 && mx < in[v]) {
        mx = in[v];
        id = v;
      }
    }
    dfs(id, -1, 1);
  }
	/*for (int i=0; i<n; ++i) {
		cout << F[i] << " ";
	}
	cout << endl;*/
	for (int i=0; i<U; ++i) {
		if (F[C[i]] && F[D[i]]) {
			//cout << F[C[i]]-1 << " " << F[D[i]]-1 << endl;
			V.push_back({F[C[i]]-1, F[D[i]]-1});
		}
	}
	InitMap(x, V.size());
	for (auto [a, b] : V) {
		MakeMap(a, b);
	}
}

Compilation message

Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:32:46: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   32 |  for (int i=0; i<n; ++i) in[i] = B[i] = F[i] = G[i] = 0, adj[i].clear();
      |                                         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4896 KB Output is correct
2 Correct 2 ms 4888 KB Output is correct
3 Correct 2 ms 4884 KB Output is correct
4 Correct 3 ms 4892 KB Output is correct
5 Correct 1 ms 4884 KB Output is correct
6 Correct 2 ms 4888 KB Output is correct
7 Correct 2 ms 4888 KB Output is correct
8 Correct 2 ms 4888 KB Output is correct
9 Correct 3 ms 4888 KB Output is correct
10 Correct 2 ms 4880 KB Output is correct
11 Correct 1 ms 4888 KB Output is correct
12 Correct 3 ms 4880 KB Output is correct
13 Correct 2 ms 4888 KB Output is correct
14 Correct 2 ms 4888 KB Output is correct
15 Correct 2 ms 4884 KB Output is correct
16 Correct 3 ms 4888 KB Output is correct
17 Correct 1 ms 4888 KB Output is correct
18 Correct 2 ms 4884 KB Output is correct
19 Correct 2 ms 4880 KB Output is correct
20 Correct 2 ms 4884 KB Output is correct
21 Correct 3 ms 4896 KB Output is correct
22 Correct 1 ms 4888 KB Output is correct
23 Correct 1 ms 4888 KB Output is correct
24 Correct 1 ms 4884 KB Output is correct
25 Correct 1 ms 4884 KB Output is correct
26 Correct 3 ms 4880 KB Output is correct
27 Correct 2 ms 4888 KB Output is correct
28 Correct 1 ms 4896 KB Output is correct
29 Correct 2 ms 4888 KB Output is correct
30 Correct 1 ms 4880 KB Output is correct
31 Correct 1 ms 4964 KB Output is correct
32 Correct 2 ms 4880 KB Output is correct
33 Correct 1 ms 4892 KB Output is correct
34 Correct 2 ms 4884 KB Output is correct
35 Correct 3 ms 4892 KB Output is correct
36 Correct 1 ms 4896 KB Output is correct
37 Correct 1 ms 4888 KB Output is correct
38 Correct 2 ms 4896 KB Output is correct
39 Correct 2 ms 4888 KB Output is correct
40 Correct 3 ms 4884 KB Output is correct
41 Correct 2 ms 4896 KB Output is correct
42 Correct 2 ms 4888 KB Output is correct
43 Correct 1 ms 4888 KB Output is correct
44 Correct 1 ms 4884 KB Output is correct
45 Correct 2 ms 4884 KB Output is correct
46 Correct 2 ms 4888 KB Output is correct
47 Correct 1 ms 4888 KB Output is correct
48 Correct 1 ms 4892 KB Output is correct
49 Correct 2 ms 4888 KB Output is correct
50 Correct 1 ms 4884 KB Output is correct
51 Correct 1 ms 4884 KB Output is correct
52 Correct 1 ms 4884 KB Output is correct
53 Correct 1 ms 4888 KB Output is correct
54 Correct 1 ms 4888 KB Output is correct
55 Correct 1 ms 4888 KB Output is correct
56 Correct 1 ms 4888 KB Output is correct
57 Correct 2 ms 4896 KB Output is correct
58 Correct 3 ms 4888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4896 KB Output is correct
2 Correct 2 ms 4888 KB Output is correct
3 Correct 2 ms 4884 KB Output is correct
4 Correct 3 ms 4892 KB Output is correct
5 Correct 1 ms 4884 KB Output is correct
6 Correct 2 ms 4888 KB Output is correct
7 Correct 2 ms 4888 KB Output is correct
8 Correct 2 ms 4888 KB Output is correct
9 Correct 3 ms 4888 KB Output is correct
10 Correct 2 ms 4880 KB Output is correct
11 Correct 1 ms 4888 KB Output is correct
12 Correct 3 ms 4880 KB Output is correct
13 Correct 2 ms 4888 KB Output is correct
14 Correct 2 ms 4888 KB Output is correct
15 Correct 2 ms 4884 KB Output is correct
16 Correct 3 ms 4888 KB Output is correct
17 Correct 1 ms 4888 KB Output is correct
18 Correct 2 ms 4884 KB Output is correct
19 Correct 2 ms 4880 KB Output is correct
20 Correct 2 ms 4884 KB Output is correct
21 Correct 3 ms 4896 KB Output is correct
22 Correct 1 ms 4888 KB Output is correct
23 Correct 1 ms 4888 KB Output is correct
24 Correct 1 ms 4884 KB Output is correct
25 Correct 1 ms 4884 KB Output is correct
26 Correct 3 ms 4880 KB Output is correct
27 Correct 2 ms 4888 KB Output is correct
28 Correct 1 ms 4896 KB Output is correct
29 Correct 2 ms 4888 KB Output is correct
30 Correct 1 ms 4880 KB Output is correct
31 Correct 1 ms 4964 KB Output is correct
32 Correct 2 ms 4880 KB Output is correct
33 Correct 1 ms 4892 KB Output is correct
34 Correct 2 ms 4884 KB Output is correct
35 Correct 3 ms 4892 KB Output is correct
36 Correct 1 ms 4896 KB Output is correct
37 Correct 1 ms 4888 KB Output is correct
38 Correct 2 ms 4896 KB Output is correct
39 Correct 2 ms 4888 KB Output is correct
40 Correct 3 ms 4884 KB Output is correct
41 Correct 2 ms 4896 KB Output is correct
42 Correct 2 ms 4888 KB Output is correct
43 Correct 1 ms 4888 KB Output is correct
44 Correct 1 ms 4884 KB Output is correct
45 Correct 2 ms 4884 KB Output is correct
46 Correct 2 ms 4888 KB Output is correct
47 Correct 1 ms 4888 KB Output is correct
48 Correct 1 ms 4892 KB Output is correct
49 Correct 2 ms 4888 KB Output is correct
50 Correct 1 ms 4884 KB Output is correct
51 Correct 1 ms 4884 KB Output is correct
52 Correct 1 ms 4884 KB Output is correct
53 Correct 1 ms 4888 KB Output is correct
54 Correct 1 ms 4888 KB Output is correct
55 Correct 1 ms 4888 KB Output is correct
56 Correct 1 ms 4888 KB Output is correct
57 Correct 2 ms 4896 KB Output is correct
58 Correct 3 ms 4888 KB Output is correct
59 Correct 3 ms 4888 KB Output is correct
60 Correct 3 ms 4888 KB Output is correct
61 Correct 2 ms 4888 KB Output is correct
62 Correct 1 ms 4896 KB Output is correct
63 Correct 2 ms 4892 KB Output is correct
64 Correct 2 ms 4888 KB Output is correct
65 Correct 4 ms 4888 KB Output is correct
66 Correct 2 ms 4896 KB Output is correct
67 Correct 1 ms 4888 KB Output is correct
68 Correct 2 ms 4888 KB Output is correct
69 Correct 2 ms 4884 KB Output is correct
70 Correct 3 ms 4884 KB Output is correct
71 Correct 2 ms 4888 KB Output is correct
72 Correct 3 ms 4896 KB Output is correct
73 Correct 3 ms 4888 KB Output is correct
74 Correct 1 ms 4888 KB Output is correct
75 Correct 1 ms 4892 KB Output is correct
76 Correct 2 ms 5140 KB Output is correct
77 Correct 3 ms 4888 KB Output is correct
78 Correct 2 ms 4888 KB Output is correct
79 Correct 3 ms 4880 KB Output is correct
80 Correct 3 ms 4884 KB Output is correct
81 Correct 1 ms 4888 KB Output is correct
82 Correct 1 ms 4888 KB Output is correct
83 Correct 1 ms 4888 KB Output is correct
84 Correct 1 ms 4888 KB Output is correct
85 Correct 3 ms 4888 KB Output is correct
86 Correct 2 ms 4888 KB Output is correct
87 Correct 2 ms 4888 KB Output is correct
88 Correct 3 ms 5136 KB Output is correct
89 Correct 1 ms 4880 KB Output is correct
90 Correct 1 ms 4884 KB Output is correct
91 Correct 2 ms 4880 KB Output is correct
92 Correct 1 ms 4884 KB Output is correct
93 Correct 1 ms 4884 KB Output is correct
94 Correct 3 ms 5004 KB Output is correct
95 Correct 3 ms 4888 KB Output is correct
96 Correct 2 ms 4888 KB Output is correct
97 Correct 3 ms 4896 KB Output is correct
98 Correct 3 ms 4884 KB Output is correct
99 Correct 1 ms 4888 KB Output is correct
100 Correct 1 ms 4896 KB Output is correct
101 Correct 1 ms 4884 KB Output is correct
102 Correct 1 ms 4880 KB Output is correct
103 Correct 1 ms 4888 KB Output is correct
104 Correct 1 ms 4888 KB Output is correct
105 Correct 2 ms 4896 KB Output is correct
106 Correct 2 ms 4900 KB Output is correct
107 Correct 3 ms 4892 KB Output is correct
108 Correct 2 ms 4888 KB Output is correct
109 Correct 2 ms 4888 KB Output is correct
110 Correct 2 ms 4888 KB Output is correct
111 Correct 1 ms 4896 KB Output is correct
112 Correct 1 ms 4888 KB Output is correct
113 Correct 2 ms 4828 KB Output is correct
114 Correct 1 ms 4888 KB Output is correct
115 Correct 1 ms 4888 KB Output is correct
116 Correct 2 ms 4888 KB Output is correct
117 Correct 1 ms 4896 KB Output is correct
118 Correct 3 ms 4888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 357 ms 33520 KB Wrong Answer [11]
2 Halted 0 ms 0 KB -