Submission #229396

# Submission time Handle Problem Language Result Execution time Memory
229396 2020-05-04T11:54:38 Z _7_7_ Hamburg Steak (JOI20_hamburg) C++14
21 / 100
3000 ms 6772 KB
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 333;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 3e5 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, k, xa[N], xb[N], ya[N], yb[N];

bool inter (int l1, int r1, int l2, int r2) {
	if (l1 > l2)  {
		swap(l1, l2);
		swap(r1, r2);
	}
	
	return l2 <= r1;
}

main () {
	srand(time(0));
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> xa[i] >> ya[i] >> xb[i] >> yb[i];

	vi bad, good, order;
	for (int i = 1; i <= n; ++i)
		bad.pb(i);



	while (1) {
		cerr << sz(good) << ' ' << sz(bad) << endl;
	    order.clear();
		random_shuffle(all(bad));

		for (int j = 1; j <= k; ++j) {
			xa[j + n] = ya[j + n] = 1; 
			yb[j + n] = xb[j + n] = inf;
		}

		for (auto x : bad)
			order.pb(x);
		for (auto x : good)
			order.pb(x);

		bad.clear();
		good.clear();

		for (auto i : order) {
			bool found = 0;
			for (int j = 1; j <= k; ++j)
				if (inter(xa[i], xb[i], xa[j + n], xb[j + n]) && inter(ya[i], yb[i], ya[j + n], yb[j + n])) {
					found = 1;
					xa[j + n] = max(xa[j + n], xa[i]);
					ya[j + n] = max(ya[j + n], ya[i]);
					xb[j + n] = min(xb[j + n], xb[i]);
					yb[j + n] = min(yb[j + n], yb[i]);
					break;	
				}			

			int j = 2;
			
			if (!found)  
				bad.pb(i);
			else 
				good.pb(i);
		}

		if (!sz(bad)) {
			for (int j = 1; j <= k; ++j)
				cout << xa[j + n] << ' ' << ya[j + n] << endl;
			return 0;
		}
	}
}




Compilation message

hamburg.cpp:50:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main () {
      |       ^
hamburg.cpp: In function 'int main()':
hamburg.cpp:92:8: warning: unused variable 'j' [-Wunused-variable]
   92 |    int j = 2;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 8 ms 432 KB Output is correct
3 Correct 7 ms 444 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 8 ms 384 KB Output is correct
12 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 7 ms 456 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Correct 8 ms 384 KB Output is correct
12 Correct 8 ms 384 KB Output is correct
13 Correct 7 ms 384 KB Output is correct
14 Correct 8 ms 384 KB Output is correct
15 Correct 8 ms 384 KB Output is correct
16 Correct 7 ms 384 KB Output is correct
17 Correct 8 ms 384 KB Output is correct
18 Correct 8 ms 408 KB Output is correct
19 Correct 7 ms 384 KB Output is correct
20 Correct 7 ms 384 KB Output is correct
21 Correct 7 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 7 ms 384 KB Output is correct
24 Correct 9 ms 384 KB Output is correct
25 Correct 7 ms 384 KB Output is correct
26 Correct 8 ms 384 KB Output is correct
27 Correct 8 ms 384 KB Output is correct
28 Correct 7 ms 384 KB Output is correct
29 Correct 7 ms 384 KB Output is correct
30 Correct 7 ms 384 KB Output is correct
31 Correct 7 ms 384 KB Output is correct
32 Correct 8 ms 384 KB Output is correct
33 Correct 7 ms 384 KB Output is correct
34 Correct 8 ms 384 KB Output is correct
35 Correct 7 ms 384 KB Output is correct
36 Correct 8 ms 384 KB Output is correct
37 Correct 8 ms 384 KB Output is correct
38 Correct 7 ms 384 KB Output is correct
39 Correct 7 ms 384 KB Output is correct
40 Correct 7 ms 384 KB Output is correct
41 Correct 7 ms 384 KB Output is correct
42 Correct 7 ms 384 KB Output is correct
43 Correct 8 ms 384 KB Output is correct
44 Correct 7 ms 384 KB Output is correct
45 Correct 7 ms 384 KB Output is correct
46 Correct 8 ms 384 KB Output is correct
47 Correct 7 ms 384 KB Output is correct
48 Correct 8 ms 384 KB Output is correct
49 Correct 7 ms 384 KB Output is correct
50 Correct 7 ms 384 KB Output is correct
51 Correct 8 ms 384 KB Output is correct
52 Correct 7 ms 384 KB Output is correct
53 Correct 7 ms 384 KB Output is correct
54 Correct 7 ms 384 KB Output is correct
55 Correct 7 ms 384 KB Output is correct
56 Correct 7 ms 416 KB Output is correct
57 Correct 7 ms 384 KB Output is correct
58 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 676 ms 6552 KB Output is correct
6 Correct 667 ms 6568 KB Output is correct
7 Correct 679 ms 6640 KB Output is correct
8 Correct 681 ms 6548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 682 ms 6600 KB Output is correct
6 Correct 684 ms 6708 KB Output is correct
7 Correct 675 ms 6644 KB Output is correct
8 Correct 690 ms 6636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 8 ms 432 KB Output is correct
3 Correct 7 ms 444 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 8 ms 384 KB Output is correct
12 Correct 7 ms 384 KB Output is correct
13 Correct 690 ms 6628 KB Output is correct
14 Correct 777 ms 6636 KB Output is correct
15 Correct 683 ms 6596 KB Output is correct
16 Correct 689 ms 6580 KB Output is correct
17 Correct 685 ms 6568 KB Output is correct
18 Correct 676 ms 6604 KB Output is correct
19 Correct 680 ms 6772 KB Output is correct
20 Correct 690 ms 6600 KB Output is correct
21 Correct 691 ms 6600 KB Output is correct
22 Correct 708 ms 6584 KB Output is correct
23 Correct 678 ms 6648 KB Output is correct
24 Correct 709 ms 6636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 7 ms 456 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Correct 8 ms 384 KB Output is correct
12 Correct 8 ms 384 KB Output is correct
13 Correct 7 ms 384 KB Output is correct
14 Correct 8 ms 384 KB Output is correct
15 Correct 8 ms 384 KB Output is correct
16 Correct 7 ms 384 KB Output is correct
17 Correct 8 ms 384 KB Output is correct
18 Correct 8 ms 408 KB Output is correct
19 Correct 7 ms 384 KB Output is correct
20 Correct 7 ms 384 KB Output is correct
21 Correct 7 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 7 ms 384 KB Output is correct
24 Correct 9 ms 384 KB Output is correct
25 Correct 7 ms 384 KB Output is correct
26 Correct 8 ms 384 KB Output is correct
27 Correct 8 ms 384 KB Output is correct
28 Correct 7 ms 384 KB Output is correct
29 Correct 7 ms 384 KB Output is correct
30 Correct 7 ms 384 KB Output is correct
31 Correct 7 ms 384 KB Output is correct
32 Correct 8 ms 384 KB Output is correct
33 Correct 7 ms 384 KB Output is correct
34 Correct 8 ms 384 KB Output is correct
35 Correct 7 ms 384 KB Output is correct
36 Correct 8 ms 384 KB Output is correct
37 Correct 8 ms 384 KB Output is correct
38 Correct 7 ms 384 KB Output is correct
39 Correct 7 ms 384 KB Output is correct
40 Correct 7 ms 384 KB Output is correct
41 Correct 7 ms 384 KB Output is correct
42 Correct 7 ms 384 KB Output is correct
43 Correct 8 ms 384 KB Output is correct
44 Correct 7 ms 384 KB Output is correct
45 Correct 7 ms 384 KB Output is correct
46 Correct 8 ms 384 KB Output is correct
47 Correct 7 ms 384 KB Output is correct
48 Correct 8 ms 384 KB Output is correct
49 Correct 7 ms 384 KB Output is correct
50 Correct 7 ms 384 KB Output is correct
51 Correct 8 ms 384 KB Output is correct
52 Correct 7 ms 384 KB Output is correct
53 Correct 7 ms 384 KB Output is correct
54 Correct 7 ms 384 KB Output is correct
55 Correct 7 ms 384 KB Output is correct
56 Correct 7 ms 416 KB Output is correct
57 Correct 7 ms 384 KB Output is correct
58 Correct 7 ms 384 KB Output is correct
59 Correct 676 ms 6588 KB Output is correct
60 Correct 718 ms 6568 KB Output is correct
61 Correct 717 ms 6540 KB Output is correct
62 Correct 682 ms 6660 KB Output is correct
63 Correct 696 ms 6532 KB Output is correct
64 Correct 711 ms 6580 KB Output is correct
65 Correct 701 ms 6568 KB Output is correct
66 Correct 687 ms 6764 KB Output is correct
67 Correct 720 ms 6628 KB Output is correct
68 Correct 714 ms 6636 KB Output is correct
69 Correct 737 ms 6676 KB Output is correct
70 Correct 706 ms 6572 KB Output is correct
71 Correct 712 ms 6584 KB Output is correct
72 Correct 713 ms 6628 KB Output is correct
73 Correct 708 ms 6588 KB Output is correct
74 Correct 730 ms 6640 KB Output is correct
75 Correct 684 ms 6648 KB Output is correct
76 Correct 717 ms 6588 KB Output is correct
77 Correct 759 ms 6544 KB Output is correct
78 Correct 695 ms 6704 KB Output is correct
79 Correct 744 ms 6648 KB Output is correct
80 Correct 692 ms 6612 KB Output is correct
81 Correct 721 ms 6648 KB Output is correct
82 Correct 703 ms 6560 KB Output is correct
83 Correct 710 ms 6612 KB Output is correct
84 Correct 680 ms 6636 KB Output is correct
85 Correct 711 ms 6636 KB Output is correct
86 Correct 682 ms 6636 KB Output is correct
87 Correct 693 ms 6636 KB Output is correct
88 Correct 696 ms 6636 KB Output is correct
89 Correct 720 ms 6572 KB Output is correct
90 Correct 749 ms 6536 KB Output is correct
91 Correct 727 ms 6660 KB Output is correct
92 Correct 719 ms 6632 KB Output is correct
93 Correct 716 ms 6592 KB Output is correct
94 Correct 770 ms 6732 KB Output is correct
95 Correct 719 ms 6636 KB Output is correct
96 Correct 719 ms 6648 KB Output is correct
97 Correct 732 ms 6664 KB Output is correct
98 Correct 712 ms 6636 KB Output is correct
99 Correct 708 ms 6584 KB Output is correct
100 Correct 717 ms 6556 KB Output is correct
101 Correct 687 ms 6636 KB Output is correct
102 Correct 716 ms 6636 KB Output is correct
103 Correct 704 ms 6636 KB Output is correct
104 Correct 736 ms 6724 KB Output is correct
105 Correct 695 ms 6552 KB Output is correct
106 Correct 710 ms 6684 KB Output is correct
107 Correct 711 ms 6600 KB Output is correct
108 Correct 699 ms 6616 KB Output is correct
109 Correct 690 ms 6764 KB Output is correct
110 Correct 701 ms 6712 KB Output is correct
111 Correct 759 ms 6628 KB Output is correct
112 Correct 687 ms 6636 KB Output is correct
113 Correct 780 ms 6636 KB Output is correct
114 Correct 680 ms 6636 KB Output is correct
115 Correct 702 ms 6644 KB Output is correct
116 Correct 693 ms 6636 KB Output is correct
117 Execution timed out 3049 ms 6632 KB Time limit exceeded
118 Halted 0 ms 0 KB -