Submission #933925

# Submission time Handle Problem Language Result Execution time Memory
933925 2024-02-26T15:06:59 Z alexander707070 Airline Route Map (JOI18_airline) C++14
0 / 100
511 ms 54980 KB
#include<bits/stdc++.h>
#include "Alicelib.h"
#define MAXN 200007

using namespace std;

namespace{
	int n,m,num;
	vector< pair<int,int> > edges;
}

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

	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 200007

using namespace std;

namespace{
	int v,u,e,cnt,root,curr;
	vector<int> g[MAXN],w,line[MAXN];
	int sp[MAXN],tim;
	vector<int> path;
	vector< pair<int,int> > ed;
	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; ed.clear();

			for(int f=0;f<u;f++){
				if(sp[C[f]]==tim or sp[D[f]]==tim)continue;
				ed.push_back({to[C[f]]-17,to[D[f]]-17});
				e++;
			}
			InitMap(V-12,e);

			for(int f=0;f<ed.size();f++){
				if(ed[f].first<0 or ed[f].first>=V-12)cout<<1/0;
				if(ed[f].second<0 or ed[f].second>=V-12)cout<<1/0;
				MakeMap(ed[f].first,ed[f].second);
			}

			return;
		}
	}

	cout<<1/0;
}

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 {anonymous}::dfs(int, int)':
Bob.cpp:19:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for(int i=0;i<line[x].size();i++){
      |               ~^~~~~~~~~~~~~~~
Bob.cpp: In function 'bool {anonymous}::ok(int)':
Bob.cpp:28:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for(int i=0;i<g[x].size();i++){
      |               ~^~~~~~~~~~~~
Bob.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int i=0;i<w.size();i++){
      |               ~^~~~~~~~~
Bob.cpp:46:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   if(e!=w.size()-1)return false;
      |      ~^~~~~~~~~~~~
Bob.cpp:49:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for(int i=0;i<w.size();i++){
      |               ~^~~~~~~~~
Bob.cpp:59:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |   for(int i=0;i<path.size();i++){
      |               ~^~~~~~~~~~~~
Bob.cpp:82:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |   for(int i=0;i<path.size();i++){
      |               ~^~~~~~~~~~~~
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:126:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  126 |    for(int f=0;f<ed.size();f++){
      |                ~^~~~~~~~~~
Bob.cpp:127:50: warning: division by zero [-Wdiv-by-zero]
  127 |     if(ed[f].first<0 or ed[f].first>=V-12)cout<<1/0;
      |                                                 ~^~
Bob.cpp:128:52: warning: division by zero [-Wdiv-by-zero]
  128 |     if(ed[f].second<0 or ed[f].second>=V-12)cout<<1/0;
      |                                                   ~^~
Bob.cpp:136:9: warning: division by zero [-Wdiv-by-zero]
  136 |  cout<<1/0;
      |        ~^~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 29284 KB Output is correct
2 Correct 7 ms 29440 KB Output is correct
3 Correct 6 ms 29444 KB Output is correct
4 Correct 6 ms 27396 KB Output is correct
5 Correct 7 ms 29444 KB Output is correct
6 Correct 7 ms 29388 KB Output is correct
7 Correct 7 ms 29480 KB Output is correct
8 Correct 6 ms 29440 KB Output is correct
9 Correct 8 ms 29416 KB Output is correct
10 Correct 6 ms 27316 KB Output is correct
11 Correct 7 ms 29444 KB Output is correct
12 Correct 6 ms 29444 KB Output is correct
13 Correct 7 ms 29444 KB Output is correct
14 Correct 6 ms 29440 KB Output is correct
15 Correct 8 ms 29444 KB Output is correct
16 Correct 6 ms 29392 KB Output is correct
17 Correct 6 ms 29440 KB Output is correct
18 Correct 6 ms 29444 KB Output is correct
19 Correct 5 ms 29444 KB Output is correct
20 Correct 7 ms 29404 KB Output is correct
21 Correct 6 ms 29444 KB Output is correct
22 Correct 7 ms 29692 KB Output is correct
23 Correct 6 ms 29364 KB Output is correct
24 Correct 6 ms 27392 KB Output is correct
25 Runtime error 20 ms 48320 KB Execution killed with signal 4
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 29284 KB Output is correct
2 Correct 7 ms 29440 KB Output is correct
3 Correct 6 ms 29444 KB Output is correct
4 Correct 6 ms 27396 KB Output is correct
5 Correct 7 ms 29444 KB Output is correct
6 Correct 7 ms 29388 KB Output is correct
7 Correct 7 ms 29480 KB Output is correct
8 Correct 6 ms 29440 KB Output is correct
9 Correct 8 ms 29416 KB Output is correct
10 Correct 6 ms 27316 KB Output is correct
11 Correct 7 ms 29444 KB Output is correct
12 Correct 6 ms 29444 KB Output is correct
13 Correct 7 ms 29444 KB Output is correct
14 Correct 6 ms 29440 KB Output is correct
15 Correct 8 ms 29444 KB Output is correct
16 Correct 6 ms 29392 KB Output is correct
17 Correct 6 ms 29440 KB Output is correct
18 Correct 6 ms 29444 KB Output is correct
19 Correct 5 ms 29444 KB Output is correct
20 Correct 7 ms 29404 KB Output is correct
21 Correct 6 ms 29444 KB Output is correct
22 Correct 7 ms 29692 KB Output is correct
23 Correct 6 ms 29364 KB Output is correct
24 Correct 6 ms 27392 KB Output is correct
25 Runtime error 20 ms 48320 KB Execution killed with signal 4
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 496 ms 54980 KB Output is correct : V - N = 12
2 Correct 321 ms 52716 KB Output is correct : V - N = 12
3 Correct 115 ms 36080 KB Output is correct : V - N = 12
4 Correct 11 ms 29884 KB Output is correct : V - N = 12
5 Correct 97 ms 32744 KB Output is correct : V - N = 12
6 Correct 318 ms 52380 KB Output is correct : V - N = 12
7 Correct 436 ms 53996 KB Output is correct : V - N = 12
8 Correct 511 ms 53224 KB Output is correct : V - N = 12
9 Correct 191 ms 36520 KB Output is correct : V - N = 12
10 Correct 24 ms 31584 KB Output is correct : V - N = 12
11 Correct 46 ms 32056 KB Output is correct : V - N = 12
12 Correct 242 ms 42620 KB Output is correct : V - N = 12
13 Correct 434 ms 53596 KB Output is correct : V - N = 12
14 Correct 424 ms 53780 KB Output is correct : V - N = 12
15 Correct 237 ms 47892 KB Output is correct : V - N = 12
16 Correct 71 ms 31960 KB Output is correct : V - N = 12
17 Correct 14 ms 30612 KB Output is correct : V - N = 12
18 Correct 160 ms 36112 KB Output is correct : V - N = 12
19 Correct 322 ms 53452 KB Output is correct : V - N = 12
20 Correct 490 ms 53616 KB Output is correct : V - N = 12
21 Correct 113 ms 34596 KB Output is correct : V - N = 12
22 Correct 88 ms 33172 KB Output is correct : V - N = 12
23 Correct 40 ms 31724 KB Output is correct : V - N = 12
24 Correct 7 ms 29448 KB Output is correct : V - N = 12
25 Correct 22 ms 31224 KB Output is correct : V - N = 12
26 Correct 69 ms 32968 KB Output is correct : V - N = 12
27 Correct 129 ms 33756 KB Output is correct : V - N = 12
28 Correct 109 ms 33860 KB Output is correct : V - N = 12
29 Correct 51 ms 31652 KB Output is correct : V - N = 12
30 Correct 9 ms 29952 KB Output is correct : V - N = 12
31 Correct 9 ms 27396 KB Output is correct : V - N = 12
32 Correct 8 ms 27396 KB Output is correct : V - N = 12
33 Correct 8 ms 27400 KB Output is correct : V - N = 12
34 Correct 10 ms 27396 KB Output is correct : V - N = 12
35 Correct 8 ms 27392 KB Output is correct : V - N = 12
36 Correct 429 ms 53332 KB Output is correct : V - N = 12
37 Correct 421 ms 53704 KB Output is correct : V - N = 12
38 Correct 425 ms 53588 KB Output is correct : V - N = 12
39 Correct 451 ms 54644 KB Output is correct : V - N = 12
40 Correct 391 ms 52852 KB Output is correct : V - N = 12
41 Correct 98 ms 33452 KB Output is correct : V - N = 12
42 Correct 65 ms 32392 KB Output is correct : V - N = 12
43 Correct 83 ms 32696 KB Output is correct : V - N = 12
44 Correct 10 ms 29700 KB Output is correct : V - N = 12
45 Correct 49 ms 31836 KB Output is correct : V - N = 12
46 Correct 199 ms 35868 KB Output is correct : V - N = 12
47 Correct 98 ms 33356 KB Output is correct : V - N = 12
48 Correct 189 ms 37164 KB Output is correct : V - N = 12
49 Correct 39 ms 32332 KB Output is correct : V - N = 12
50 Correct 15 ms 30320 KB Output is correct : V - N = 12
51 Correct 394 ms 53304 KB Output is correct : V - N = 12
52 Correct 10 ms 29692 KB Output is correct : V - N = 12
53 Correct 287 ms 52348 KB Output is correct : V - N = 12
54 Correct 376 ms 52016 KB Output is correct : V - N = 12
55 Correct 25 ms 31364 KB Output is correct : V - N = 12
56 Correct 261 ms 41984 KB Output is correct : V - N = 12
57 Correct 438 ms 52412 KB Output is correct : V - N = 12
58 Correct 71 ms 32240 KB Output is correct : V - N = 12
59 Correct 158 ms 36428 KB Output is correct : V - N = 12
60 Correct 403 ms 53408 KB Output is correct : V - N = 12
61 Correct 7 ms 29448 KB Output is correct : V - N = 12
62 Correct 6 ms 29444 KB Output is correct : V - N = 12
63 Correct 6 ms 29444 KB Output is correct : V - N = 12
64 Correct 7 ms 29444 KB Output is correct : V - N = 12
65 Correct 7 ms 29440 KB Output is correct : V - N = 12
66 Correct 7 ms 29444 KB Output is correct : V - N = 12
67 Correct 7 ms 29444 KB Output is correct : V - N = 12
68 Correct 6 ms 29444 KB Output is correct : V - N = 12
69 Correct 6 ms 29372 KB Output is correct : V - N = 12
70 Correct 7 ms 29444 KB Output is correct : V - N = 12
71 Correct 7 ms 29444 KB Output is correct : V - N = 12
72 Correct 7 ms 29444 KB Output is correct : V - N = 12
73 Correct 6 ms 29444 KB Output is correct : V - N = 12
74 Correct 6 ms 29444 KB Output is correct : V - N = 12
75 Correct 7 ms 29444 KB Output is correct : V - N = 12
76 Correct 6 ms 29444 KB Output is correct : V - N = 12
77 Runtime error 23 ms 48244 KB Execution killed with signal 4
78 Halted 0 ms 0 KB -