Submission #211510

# Submission time Handle Problem Language Result Execution time Memory
211510 2020-03-20T16:25:19 Z dimash241 Hamburg Steak (JOI20_hamburg) C++17
21 / 100
3000 ms 6224 KB
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

//# include <ext/pb_ds/assoc_container.hpp>
//# include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 2e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int ax[N], bx[N], ay[N], by[N];
int p[N];
int ord[5];
int mxL[5];
int mnR[5];
int mxU[5];
int mnD[5];

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline void chmx (int &a, int b) {
	if (a < b) a = b;
}
inline void chmn (int &a, int b) {
	if (a > b) a = b;
}

inline void solve () {
	for (int i = 1; i <= k; ++i) {
		mxL[i] = mxU[i] = 1;
		mnR[i] = mnD[i] = 1e9; 
	}
	vector < int > bad, aa;

	for (int ii = 1, i; ii <= n; ++ii) {
		i = p[ii];
		bool ff = 0;
		for (int j = 1; j <= k; ++j) {
			int L = mxL[j];
			int U = mxU[j];
			int D = mnD[j];
			int R = mnR[j];
			chmx(L, ax[i]);
			chmx(U, bx[i]);
			chmn(R, ay[i]);
			chmn(D, by[i]);
			if (L > R) continue;
			if (U > D) continue;
			ff = 1;
			mxL[j] = L;
			mnR[j] = R;
			mnD[j] = D;
			mxU[j] = U;

			break;
		}
		if(!ff) bad.pb(i);
		else aa.pb(i);
	}
	if (bad.empty()) {
		for (int j = 1; j <= k; ++j) {
			cout << mxL[j] << ' ' << mxU[j] << '\n';
		}
		exit(0);
	}
	shuffle(every(bad), rng);
	for (int i = 1; i <= n; i ++) {
		if (i > sz(bad)) p[i] = aa[i-sz(bad) - 1];
		else p[i] = bad[i-1];
	}
}

int main () {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d%d%d", &ax[i], &bx[i], &ay[i], &by[i]);
		p[i] = i;
	}
	while (true) solve();

	return Accepted;
}

// First :D

Compilation message

hamburg.cpp: In function 'int main()':
hamburg.cpp:117:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  117 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
hamburg.cpp:119:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  119 |   scanf("%d%d%d%d", &ax[i], &bx[i], &ay[i], &by[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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 3 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 3 ms 360 KB Output is correct
8 Correct 2 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
# Verdict Execution time Memory 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 3 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 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 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 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 436 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 2 ms 360 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 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 3 ms 384 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 3 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 2 ms 384 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 2 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 3 ms 384 KB Output is correct
58 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 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 149 ms 5424 KB Output is correct
6 Correct 150 ms 5364 KB Output is correct
7 Correct 147 ms 5360 KB Output is correct
8 Correct 144 ms 5488 KB Output is correct
# Verdict Execution time Memory 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 144 ms 6052 KB Output is correct
6 Correct 170 ms 6048 KB Output is correct
7 Correct 152 ms 6048 KB Output is correct
8 Correct 179 ms 6040 KB Output is correct
# Verdict Execution time Memory 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 3 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 3 ms 360 KB Output is correct
8 Correct 2 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 161 ms 6108 KB Output is correct
14 Correct 203 ms 6040 KB Output is correct
15 Correct 173 ms 6016 KB Output is correct
16 Correct 139 ms 6016 KB Output is correct
17 Correct 144 ms 5984 KB Output is correct
18 Correct 139 ms 6040 KB Output is correct
19 Correct 148 ms 6048 KB Output is correct
20 Correct 154 ms 6076 KB Output is correct
21 Correct 155 ms 6052 KB Output is correct
22 Correct 159 ms 6044 KB Output is correct
23 Correct 159 ms 6012 KB Output is correct
24 Correct 142 ms 6048 KB Output is correct
# Verdict Execution time Memory 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 3 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 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 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 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 436 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 2 ms 360 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 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 3 ms 384 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 3 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 2 ms 384 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 2 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 3 ms 384 KB Output is correct
58 Correct 2 ms 384 KB Output is correct
59 Correct 155 ms 6032 KB Output is correct
60 Correct 147 ms 6064 KB Output is correct
61 Correct 139 ms 6036 KB Output is correct
62 Correct 139 ms 5984 KB Output is correct
63 Correct 177 ms 6088 KB Output is correct
64 Correct 155 ms 6192 KB Output is correct
65 Correct 179 ms 6020 KB Output is correct
66 Correct 144 ms 6004 KB Output is correct
67 Correct 160 ms 6084 KB Output is correct
68 Correct 181 ms 6084 KB Output is correct
69 Correct 170 ms 6208 KB Output is correct
70 Correct 157 ms 6064 KB Output is correct
71 Correct 173 ms 6104 KB Output is correct
72 Correct 212 ms 6036 KB Output is correct
73 Correct 161 ms 6056 KB Output is correct
74 Correct 144 ms 5988 KB Output is correct
75 Correct 180 ms 6088 KB Output is correct
76 Correct 154 ms 6076 KB Output is correct
77 Correct 194 ms 6104 KB Output is correct
78 Correct 192 ms 6104 KB Output is correct
79 Correct 190 ms 6096 KB Output is correct
80 Correct 150 ms 6008 KB Output is correct
81 Correct 167 ms 6064 KB Output is correct
82 Correct 168 ms 6052 KB Output is correct
83 Correct 172 ms 6024 KB Output is correct
84 Correct 142 ms 6040 KB Output is correct
85 Correct 157 ms 6100 KB Output is correct
86 Correct 206 ms 6144 KB Output is correct
87 Correct 191 ms 6224 KB Output is correct
88 Correct 163 ms 6020 KB Output is correct
89 Correct 145 ms 6012 KB Output is correct
90 Correct 189 ms 6040 KB Output is correct
91 Correct 178 ms 6108 KB Output is correct
92 Correct 221 ms 6084 KB Output is correct
93 Correct 144 ms 6008 KB Output is correct
94 Correct 165 ms 6068 KB Output is correct
95 Correct 158 ms 6028 KB Output is correct
96 Correct 167 ms 6216 KB Output is correct
97 Correct 161 ms 6084 KB Output is correct
98 Correct 145 ms 6104 KB Output is correct
99 Correct 179 ms 6076 KB Output is correct
100 Correct 166 ms 6104 KB Output is correct
101 Correct 163 ms 6104 KB Output is correct
102 Correct 152 ms 6092 KB Output is correct
103 Correct 168 ms 5996 KB Output is correct
104 Correct 176 ms 6060 KB Output is correct
105 Correct 153 ms 6096 KB Output is correct
106 Correct 184 ms 6064 KB Output is correct
107 Correct 169 ms 6112 KB Output is correct
108 Correct 153 ms 6048 KB Output is correct
109 Correct 178 ms 6072 KB Output is correct
110 Correct 155 ms 6108 KB Output is correct
111 Correct 160 ms 6124 KB Output is correct
112 Correct 154 ms 6008 KB Output is correct
113 Correct 145 ms 6020 KB Output is correct
114 Correct 143 ms 6020 KB Output is correct
115 Correct 145 ms 6020 KB Output is correct
116 Correct 142 ms 6068 KB Output is correct
117 Execution timed out 3047 ms 6216 KB Time limit exceeded
118 Halted 0 ms 0 KB -