답안 #229397

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
229397 2020-05-04T11:56:24 Z _7_7_ 함박 스테이크 (JOI20_hamburg) C++14
21 / 100
3000 ms 6728 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 = 2e5 + 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));
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i)
		scanf("%d%d%d%d", &xa[i], &ya[i], &xb[i], &yb[i]);

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



	while (1) {
	    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:91:8: warning: unused variable 'j' [-Wunused-variable]
   91 |    int j = 2;
      |        ^
hamburg.cpp:52:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   52 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
hamburg.cpp:54:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   54 |   scanf("%d%d%d%d", &xa[i], &ya[i], &xb[i], &yb[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 2 ms 416 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 3 ms 384 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 3 ms 384 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 2 ms 384 KB Output is correct
54 Correct 2 ms 384 KB Output is correct
55 Correct 2 ms 384 KB Output is correct
56 Correct 2 ms 384 KB Output is correct
57 Correct 2 ms 384 KB Output is correct
58 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 151 ms 6628 KB Output is correct
6 Correct 144 ms 6508 KB Output is correct
7 Correct 166 ms 6512 KB Output is correct
8 Correct 151 ms 6508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 174 ms 6548 KB Output is correct
6 Correct 154 ms 6508 KB Output is correct
7 Correct 172 ms 6624 KB Output is correct
8 Correct 152 ms 6508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 153 ms 6556 KB Output is correct
14 Correct 166 ms 6508 KB Output is correct
15 Correct 165 ms 6508 KB Output is correct
16 Correct 154 ms 6636 KB Output is correct
17 Correct 153 ms 6508 KB Output is correct
18 Correct 156 ms 6508 KB Output is correct
19 Correct 162 ms 6508 KB Output is correct
20 Correct 190 ms 6544 KB Output is correct
21 Correct 169 ms 6512 KB Output is correct
22 Correct 178 ms 6624 KB Output is correct
23 Correct 153 ms 6508 KB Output is correct
24 Correct 185 ms 6508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 2 ms 416 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 3 ms 384 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 3 ms 384 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 2 ms 384 KB Output is correct
54 Correct 2 ms 384 KB Output is correct
55 Correct 2 ms 384 KB Output is correct
56 Correct 2 ms 384 KB Output is correct
57 Correct 2 ms 384 KB Output is correct
58 Correct 3 ms 384 KB Output is correct
59 Correct 160 ms 6508 KB Output is correct
60 Correct 162 ms 6548 KB Output is correct
61 Correct 151 ms 6508 KB Output is correct
62 Correct 172 ms 6636 KB Output is correct
63 Correct 170 ms 6508 KB Output is correct
64 Correct 158 ms 6508 KB Output is correct
65 Correct 166 ms 6556 KB Output is correct
66 Correct 168 ms 6508 KB Output is correct
67 Correct 177 ms 6612 KB Output is correct
68 Correct 152 ms 6508 KB Output is correct
69 Correct 192 ms 6636 KB Output is correct
70 Correct 161 ms 6508 KB Output is correct
71 Correct 167 ms 6636 KB Output is correct
72 Correct 157 ms 6612 KB Output is correct
73 Correct 202 ms 6508 KB Output is correct
74 Correct 167 ms 6508 KB Output is correct
75 Correct 180 ms 6508 KB Output is correct
76 Correct 199 ms 6508 KB Output is correct
77 Correct 178 ms 6620 KB Output is correct
78 Correct 161 ms 6508 KB Output is correct
79 Correct 163 ms 6508 KB Output is correct
80 Correct 188 ms 6508 KB Output is correct
81 Correct 162 ms 6636 KB Output is correct
82 Correct 182 ms 6560 KB Output is correct
83 Correct 175 ms 6508 KB Output is correct
84 Correct 179 ms 6508 KB Output is correct
85 Correct 179 ms 6508 KB Output is correct
86 Correct 155 ms 6508 KB Output is correct
87 Correct 169 ms 6508 KB Output is correct
88 Correct 172 ms 6520 KB Output is correct
89 Correct 185 ms 6508 KB Output is correct
90 Correct 195 ms 6636 KB Output is correct
91 Correct 178 ms 6568 KB Output is correct
92 Correct 163 ms 6572 KB Output is correct
93 Correct 191 ms 6608 KB Output is correct
94 Correct 174 ms 6648 KB Output is correct
95 Correct 188 ms 6508 KB Output is correct
96 Correct 196 ms 6556 KB Output is correct
97 Correct 172 ms 6540 KB Output is correct
98 Correct 156 ms 6636 KB Output is correct
99 Correct 205 ms 6508 KB Output is correct
100 Correct 178 ms 6588 KB Output is correct
101 Correct 158 ms 6508 KB Output is correct
102 Correct 181 ms 6548 KB Output is correct
103 Correct 181 ms 6568 KB Output is correct
104 Correct 187 ms 6620 KB Output is correct
105 Correct 199 ms 6508 KB Output is correct
106 Correct 195 ms 6728 KB Output is correct
107 Correct 186 ms 6508 KB Output is correct
108 Correct 174 ms 6508 KB Output is correct
109 Correct 207 ms 6624 KB Output is correct
110 Correct 176 ms 6508 KB Output is correct
111 Correct 186 ms 6508 KB Output is correct
112 Correct 182 ms 6508 KB Output is correct
113 Correct 174 ms 6568 KB Output is correct
114 Correct 168 ms 6508 KB Output is correct
115 Correct 178 ms 6508 KB Output is correct
116 Correct 178 ms 6508 KB Output is correct
117 Execution timed out 3084 ms 6508 KB Time limit exceeded
118 Halted 0 ms 0 KB -