답안 #933906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
933906 2024-02-26T14:48:18 Z alexander707070 항공 노선도 (JOI18_airline) C++14
0 / 100
488 ms 35628 KB
#include<bits/stdc++.h>
#include "Alicelib.h"
#define MAXN 2007

using namespace std;

int n,m,num;
vector< pair<int,int> > edges;

void Alice( int N, int M, int A[], int B[]){

	srand(42069);

	n=N; m=M;
	num=17;

	for(int i=0;i<n;i++){
		for(int f=10;f>=0;f--){
			if(((1<<f)&(i+num))>0)edges.push_back({i,n+f});
		}
	}

	for(int i=n;i<=n+10;i++){
		edges.push_back({i,n+11});
		if(i<n+10)edges.push_back({i,i+1});
	}

	for(int i=0;i<m;i++){
		edges.push_back({A[i],B[i]});
	}

	InitG( n+12, edges.size() );
	for(int i=0;i<edges.size();i++){
		MakeG(i,edges[i].first,edges[i].second);
	}
}

#include <bits/stdc++.h>
#include "Boblib.h"
#define MAXN 2007

using namespace std;

int v,u,e,cnt,root,curr;
vector<int> g[MAXN],w,line[MAXN];
int sp[MAXN],tim;
vector<int> path;
int used2[MAXN],tim2,pos[MAXN],to[MAXN];
bool dali;

void dfs(int x,int p){
	path.push_back(x);

	for(int i=0;i<line[x].size();i++){
		if(line[x][i]==p)continue;
		dfs(line[x][i],x);
	}
}

bool ok(int x){
	w.clear(); tim++; e=0;

	for(int i=0;i<g[x].size();i++){
		w.push_back(g[x][i]);
		sp[w.back()]=tim;

		line[w.back()].clear();
	}

	for(int i=0;i<w.size();i++){
		for(int f:g[w[i]]){
			if(sp[f]==tim and f>w[i]){
				e++;

				line[w[i]].push_back(f);
				line[f].push_back(w[i]);
			}
		}
	}

	if(e!=w.size()-1)return false;
	
	cnt=0;
	for(int i=0;i<w.size();i++){
		if(line[w[i]].size()!=1 and line[w[i]].size()!=2)return false;
		if(line[w[i]].size()==1){
			cnt++; root=w[i];
		}
	}

	if(cnt!=2)return false;
	path.clear(); dfs(root,0);

	for(int i=0;i<path.size();i++){
		pos[path[i]]=i;
	}

	tim2++; dali=true;
	for(int f=0;f<v;f++){
		if(f==x or sp[f]==tim)continue;

		curr=0;
		for(int k:g[f]){
			if(sp[k]!=tim)continue;
			curr+=(1<<pos[k]);
		}
		to[f]=curr;

		if(used2[curr]==tim2 or curr<17 or curr>=v-12+17){dali=false;break;}
		used2[curr]=tim2;
	}

	if(dali)return true;

	reverse(path.begin(),path.end());

	for(int i=0;i<path.size();i++){
		pos[path[i]]=i;
	}

	tim2++; dali=true;
	for(int f=0;f<v;f++){
		if(f==x or sp[f]==tim)continue;

		curr=0;
		for(int k:g[f]){
			if(sp[k]!=tim)continue;
			curr+=(1<<pos[k]);
		}
		to[f]=curr;

		if(used2[curr]==tim2 or curr<17 or curr>=v-12+17){dali=false;break;}
		used2[curr]=tim2;
	}

	if(dali)return true;

	return false;
}

void Bob( int V, int U, int C[], int D[] ){

	v=V; u=U;
	for(int i=0;i<u;i++){
		g[C[i]].push_back(D[i]);
		g[D[i]].push_back(C[i]);
	}

	for(int i=0;i<v;i++){
		if(g[i].size()==11 and ok(i)){
			e=0;
			for(int f=0;f<u;f++){
				if(sp[C[f]]==tim or sp[D[f]]==tim)continue;
				e++;
			}
			InitMap(V-12,e);

			for(int f=0;f<u;f++){
				if(sp[C[f]]==tim or sp[D[f]]==tim)continue;
				MakeMap(to[C[f]]-17,to[D[f]]-17);
			}
		}
	}

}

Compilation message

Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for(int i=0;i<edges.size();i++){
      |              ~^~~~~~~~~~~~~

Bob.cpp: In function 'void dfs(int, int)':
Bob.cpp:17:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i=0;i<line[x].size();i++){
      |              ~^~~~~~~~~~~~~~~
Bob.cpp: In function 'bool ok(int)':
Bob.cpp:26:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for(int i=0;i<g[x].size();i++){
      |              ~^~~~~~~~~~~~
Bob.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for(int i=0;i<w.size();i++){
      |              ~^~~~~~~~~
Bob.cpp:44:6: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  if(e!=w.size()-1)return false;
      |     ~^~~~~~~~~~~~
Bob.cpp:47:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |  for(int i=0;i<w.size();i++){
      |              ~^~~~~~~~~
Bob.cpp:57:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(int i=0;i<path.size();i++){
      |              ~^~~~~~~~~~~~
Bob.cpp:80:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |  for(int i=0;i<path.size();i++){
      |              ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15620 KB Output is correct
2 Incorrect 3 ms 15620 KB Wrong Answer [17]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15620 KB Output is correct
2 Incorrect 3 ms 15620 KB Wrong Answer [17]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 487 ms 34776 KB Output is correct : V - N = 12
2 Correct 342 ms 34032 KB Output is correct : V - N = 12
3 Correct 147 ms 19476 KB Output is correct : V - N = 12
4 Correct 8 ms 16088 KB Output is correct : V - N = 12
5 Correct 73 ms 18168 KB Output is correct : V - N = 12
6 Correct 272 ms 32548 KB Output is correct : V - N = 12
7 Correct 467 ms 35592 KB Output is correct : V - N = 12
8 Correct 392 ms 34032 KB Output is correct : V - N = 12
9 Correct 180 ms 21292 KB Output is correct : V - N = 12
10 Correct 23 ms 16872 KB Output is correct : V - N = 12
11 Correct 44 ms 17800 KB Output is correct : V - N = 12
12 Correct 269 ms 26244 KB Output is correct : V - N = 12
13 Correct 370 ms 35168 KB Output is correct : V - N = 12
14 Correct 442 ms 34192 KB Output is correct : V - N = 12
15 Correct 306 ms 28692 KB Output is correct : V - N = 12
16 Correct 61 ms 17568 KB Output is correct : V - N = 12
17 Correct 12 ms 16484 KB Output is correct : V - N = 12
18 Correct 188 ms 20536 KB Output is correct : V - N = 12
19 Correct 405 ms 33516 KB Output is correct : V - N = 12
20 Correct 401 ms 34876 KB Output is correct : V - N = 12
21 Correct 98 ms 19536 KB Output is correct : V - N = 12
22 Correct 72 ms 18580 KB Output is correct : V - N = 12
23 Correct 32 ms 18048 KB Output is correct : V - N = 12
24 Correct 4 ms 15620 KB Output is correct : V - N = 12
25 Correct 21 ms 16840 KB Output is correct : V - N = 12
26 Correct 79 ms 18844 KB Output is correct : V - N = 12
27 Correct 102 ms 18308 KB Output is correct : V - N = 12
28 Correct 100 ms 17916 KB Output is correct : V - N = 12
29 Correct 43 ms 17288 KB Output is correct : V - N = 12
30 Correct 6 ms 16124 KB Output is correct : V - N = 12
31 Correct 5 ms 13828 KB Output is correct : V - N = 12
32 Correct 5 ms 13824 KB Output is correct : V - N = 12
33 Correct 6 ms 13828 KB Output is correct : V - N = 12
34 Correct 5 ms 13828 KB Output is correct : V - N = 12
35 Correct 5 ms 13760 KB Output is correct : V - N = 12
36 Correct 412 ms 35628 KB Output is correct : V - N = 12
37 Correct 383 ms 34676 KB Output is correct : V - N = 12
38 Correct 488 ms 34996 KB Output is correct : V - N = 12
39 Correct 365 ms 34676 KB Output is correct : V - N = 12
40 Correct 382 ms 35232 KB Output is correct : V - N = 12
41 Correct 64 ms 19256 KB Output is correct : V - N = 12
42 Correct 51 ms 18364 KB Output is correct : V - N = 12
43 Correct 65 ms 18144 KB Output is correct : V - N = 12
44 Correct 6 ms 16136 KB Output is correct : V - N = 12
45 Correct 36 ms 18052 KB Output is correct : V - N = 12
46 Correct 122 ms 20316 KB Output is correct : V - N = 12
47 Correct 63 ms 18468 KB Output is correct : V - N = 12
48 Correct 225 ms 20888 KB Output is correct : V - N = 12
49 Correct 36 ms 17668 KB Output is correct : V - N = 12
50 Correct 11 ms 16980 KB Output is correct : V - N = 12
51 Correct 354 ms 33272 KB Output is correct : V - N = 12
52 Correct 7 ms 16180 KB Output is correct : V - N = 12
53 Correct 279 ms 32588 KB Output is correct : V - N = 12
54 Correct 328 ms 34108 KB Output is correct : V - N = 12
55 Correct 22 ms 17308 KB Output is correct : V - N = 12
56 Correct 202 ms 26512 KB Output is correct : V - N = 12
57 Correct 452 ms 34928 KB Output is correct : V - N = 12
58 Correct 70 ms 17616 KB Output is correct : V - N = 12
59 Correct 138 ms 20336 KB Output is correct : V - N = 12
60 Correct 363 ms 34212 KB Output is correct : V - N = 12
61 Correct 3 ms 15620 KB Output is correct : V - N = 12
62 Correct 3 ms 15616 KB Output is correct : V - N = 12
63 Correct 3 ms 15620 KB Output is correct : V - N = 12
64 Correct 3 ms 15616 KB Output is correct : V - N = 12
65 Correct 3 ms 15620 KB Output is correct : V - N = 12
66 Correct 3 ms 15620 KB Output is correct : V - N = 12
67 Correct 3 ms 15620 KB Output is correct : V - N = 12
68 Correct 3 ms 15620 KB Output is correct : V - N = 12
69 Correct 3 ms 15548 KB Output is correct : V - N = 12
70 Correct 3 ms 15616 KB Output is correct : V - N = 12
71 Correct 3 ms 15620 KB Output is correct : V - N = 12
72 Correct 3 ms 15620 KB Output is correct : V - N = 12
73 Correct 3 ms 15620 KB Output is correct : V - N = 12
74 Correct 3 ms 15616 KB Output is correct : V - N = 12
75 Correct 3 ms 15620 KB Output is correct : V - N = 12
76 Correct 3 ms 15620 KB Output is correct : V - N = 12
77 Correct 3 ms 15872 KB Output is correct : V - N = 12
78 Correct 3 ms 15620 KB Output is correct : V - N = 12
79 Correct 3 ms 15532 KB Output is correct : V - N = 12
80 Correct 3 ms 15616 KB Output is correct : V - N = 12
81 Correct 3 ms 15728 KB Output is correct : V - N = 12
82 Correct 3 ms 15620 KB Output is correct : V - N = 12
83 Correct 3 ms 15620 KB Output is correct : V - N = 12
84 Correct 3 ms 15620 KB Output is correct : V - N = 12
85 Correct 3 ms 15620 KB Output is correct : V - N = 12
86 Correct 3 ms 15616 KB Output is correct : V - N = 12
87 Correct 3 ms 15620 KB Output is correct : V - N = 12
88 Correct 3 ms 15616 KB Output is correct : V - N = 12
89 Correct 3 ms 15868 KB Output is correct : V - N = 12
90 Correct 3 ms 15616 KB Output is correct : V - N = 12
91 Correct 3 ms 13572 KB Output is correct : V - N = 12
92 Correct 3 ms 13568 KB Output is correct : V - N = 12
93 Correct 3 ms 13572 KB Output is correct : V - N = 12
94 Correct 2 ms 13572 KB Output is correct : V - N = 12
95 Correct 2 ms 13568 KB Output is correct : V - N = 12
96 Correct 3 ms 15620 KB Output is correct : V - N = 12
97 Correct 3 ms 15656 KB Output is correct : V - N = 12
98 Correct 3 ms 15620 KB Output is correct : V - N = 12
99 Correct 3 ms 15620 KB Output is correct : V - N = 12
100 Correct 3 ms 15620 KB Output is correct : V - N = 12
101 Correct 3 ms 15620 KB Output is correct : V - N = 12
102 Correct 3 ms 15620 KB Output is correct : V - N = 12
103 Correct 3 ms 15616 KB Output is correct : V - N = 12
104 Correct 2 ms 13572 KB Output is correct : V - N = 12
105 Correct 3 ms 15612 KB Output is correct : V - N = 12
106 Correct 3 ms 15620 KB Output is correct : V - N = 12
107 Correct 3 ms 15616 KB Output is correct : V - N = 12
108 Correct 3 ms 15620 KB Output is correct : V - N = 12
109 Correct 3 ms 15620 KB Output is correct : V - N = 12
110 Correct 3 ms 15616 KB Output is correct : V - N = 12
111 Correct 3 ms 15620 KB Output is correct : V - N = 12
112 Correct 3 ms 15620 KB Output is correct : V - N = 12
113 Correct 3 ms 15620 KB Output is correct : V - N = 12
114 Correct 3 ms 15624 KB Output is correct : V - N = 12
115 Correct 3 ms 15620 KB Output is correct : V - N = 12
116 Correct 3 ms 15620 KB Output is correct : V - N = 12
117 Correct 3 ms 15620 KB Output is correct : V - N = 12
118 Correct 3 ms 16124 KB Output is correct : V - N = 12
119 Correct 3 ms 15624 KB Output is correct : V - N = 12
120 Incorrect 3 ms 15620 KB Wrong Answer [17]
121 Halted 0 ms 0 KB -