Submission #213399

# Submission time Handle Problem Language Result Execution time Memory
213399 2020-03-25T17:22:49 Z popovicirobert Hamburg Steak (JOI20_hamburg) C++14
6 / 100
3000 ms 3456 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define uint unsigned int


using namespace std;

const int INF = (int) 1e9;

struct Rect {
	int x1, y1, x2, y2;
	Rect(int _x1 = 1, int _y1 = 1, int _x2 = INF, int _y2 = INF) : x1(_x1), y1(_y1), x2(_x2), y2(_y2) {}
	bool ok() {
		return x1 <= x2 && y1 <= y2;
	}
};

inline Rect inter(Rect a, Rect b) {
	return Rect(max(a.x1, b.x1), max(a.y1, b.y1), min(a.x2, b.x2), min(a.y2, b.y2));
}

int main() {
#ifdef HOME
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, n, k;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> k;
    vector<Rect> r(n);
    for(i = 0; i < n; i++) {
    	cin >> r[i].x1 >> r[i].y1 >> r[i].x2 >> r[i].y2;
    }

    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    while(true) {
    	shuffle(r.begin(), r.end(), rng);
    	vector<Rect> sol(k);
    	bool bad = 0;
    	for(i = 0; i < n && bad == 0; i++) {
    		bad = 1;
    		for(int j = 0; j < k; j++) {
    			if(inter(sol[j], r[i]).ok()) {
    				sol[j] = inter(sol[j], r[i]);
    				bad = 0;
    				break;
    			}
    		}
    	}
    	if(bad == 0) {
    		for(i = 0; i < k; i++) {
    			cout << sol[i].x1 << " " << sol[i].y1 << "\n";
    		}
    		return 0;
    	}
    }

    return 0;
}
# 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 1 ms 384 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 4 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
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 129 ms 420 KB Output is correct
9 Correct 24 ms 384 KB Output is correct
10 Correct 26 ms 384 KB Output is correct
11 Correct 14 ms 384 KB Output is correct
12 Correct 3 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 4 ms 424 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 107 ms 384 KB Output is correct
9 Correct 315 ms 412 KB Output is correct
10 Correct 80 ms 384 KB Output is correct
11 Correct 327 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 1958 ms 420 KB Output is correct
14 Correct 51 ms 384 KB Output is correct
15 Correct 19 ms 384 KB Output is correct
16 Correct 443 ms 384 KB Output is correct
17 Correct 316 ms 384 KB Output is correct
18 Correct 382 ms 384 KB Output is correct
19 Correct 56 ms 384 KB Output is correct
20 Execution timed out 3063 ms 384 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# 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 1 ms 384 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 114 ms 3456 KB Output is correct
6 Correct 126 ms 3456 KB Output is correct
7 Correct 104 ms 3456 KB Output is correct
8 Correct 105 ms 3456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 544 ms 3456 KB Output is correct
6 Execution timed out 3051 ms 3456 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 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 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 129 ms 420 KB Output is correct
9 Correct 24 ms 384 KB Output is correct
10 Correct 26 ms 384 KB Output is correct
11 Correct 14 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2411 ms 3456 KB Output is correct
14 Correct 146 ms 3456 KB Output is correct
15 Execution timed out 3062 ms 3456 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 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 4 ms 424 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 107 ms 384 KB Output is correct
9 Correct 315 ms 412 KB Output is correct
10 Correct 80 ms 384 KB Output is correct
11 Correct 327 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 1958 ms 420 KB Output is correct
14 Correct 51 ms 384 KB Output is correct
15 Correct 19 ms 384 KB Output is correct
16 Correct 443 ms 384 KB Output is correct
17 Correct 316 ms 384 KB Output is correct
18 Correct 382 ms 384 KB Output is correct
19 Correct 56 ms 384 KB Output is correct
20 Execution timed out 3063 ms 384 KB Time limit exceeded
21 Halted 0 ms 0 KB -