提出 #73305563


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define A array <int, 3>

const int N = 200010;

int h, w, n;
int l[N], r[N];
int X[N], Y[N];
set <A> s, t;

int main() {
	cin >> h >> w >> n;
	for (int i = 1 ; i <= n ; i++)
		cin >> l[i] >> r[i], s.insert({l[i], r[i], i}), t.insert({r[i], l[i], i});
	for (int i = 1 ; i <= n ; i++) {
		auto it = s.lower_bound((A){h, -1, -1});
		if (it != s.end() && (*it)[0] == h) {
			int x = (*it)[2];
			X[x] = 1, Y[x] = w - r[x] + 1;
			w -= r[x];
			s.erase({l[x], r[x], x});
			t.erase({r[x], l[x], x});
		} else {
			it = t.lower_bound((A){w, -1, -1});
			assert(it != t.end() && (*it)[0] == w);
			int x = (*it)[2];
			X[x] = h - l[x] + 1, Y[x] = 1;
			h -= l[x];
			s.erase({l[x], r[x], x});
			t.erase({r[x], l[x], x});
		}
	}
	for (int i = 1 ; i <= n ; i++) cout << X[i] << " " << Y[i] << endl;
	return 0;
}

提出情報

提出日時
問題 D - Reconstruct Chocolate
ユーザ dongzirui0817
言語 C++ IOI-Style(GNU++20) (GCC 14.2.0)
得点 425
コード長 908 Byte
結果 AC
実行時間 463 ms
メモリ 30944 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 425 / 425
結果
AC × 2
AC × 19
セット名 テストケース
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 02_biased_cut_01.txt, 02_biased_cut_02.txt, 02_biased_cut_03.txt
ケース名 結果 実行時間 メモリ
00_sample_01.txt AC 0 ms 1776 KiB
00_sample_02.txt AC 0 ms 1776 KiB
01_random_01.txt AC 443 ms 30880 KiB
01_random_02.txt AC 444 ms 30944 KiB
01_random_03.txt AC 423 ms 30624 KiB
01_random_04.txt AC 431 ms 30700 KiB
01_random_05.txt AC 442 ms 30812 KiB
01_random_06.txt AC 430 ms 30860 KiB
01_random_07.txt AC 448 ms 30844 KiB
01_random_08.txt AC 449 ms 30836 KiB
01_random_09.txt AC 442 ms 30780 KiB
01_random_10.txt AC 463 ms 30728 KiB
01_random_11.txt AC 450 ms 30772 KiB
01_random_12.txt AC 436 ms 30792 KiB
01_random_13.txt AC 446 ms 30940 KiB
01_random_14.txt AC 427 ms 30536 KiB
02_biased_cut_01.txt AC 349 ms 30768 KiB
02_biased_cut_02.txt AC 345 ms 30852 KiB
02_biased_cut_03.txt AC 454 ms 30944 KiB