Submission #73327635


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
struct rect{
    int h, w, i;
    bool v;
};
bool rect_sort(rect r1, rect r2){
    int v1 = max(r1.h,r1.w);
    int v2 = max(r2.h,r2.w);
    return v1 > v2;
}
int main(){
    int h, w, n; cin >> h >> w >> n;
    vector<rect> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i].h >> v[i].w;
        v[i].i = i;
        v[i].v = false;
    }
    sort(v.begin(),v.end(), rect_sort);
    vector<pair<int,int>> res(n);
    pair<int,int> curr = {1,1};
    int bound = n-1;
    for(int _ = 0; _ < n; _++){
        for(int i = bound; i >= 0; i--){
            if(v[i].v) continue;
            if(v[i].w == w){
                res[v[i].i] = curr;
                curr.first += v[i].h;
                h -= v[i].h;
            } else if(v[i].h == h){
                res[v[i].i] = curr;
                curr.second += v[i].w;
                w -= v[i].w;
            } else continue;
            v[i].v = true;
            if(i == bound){
                bound--;
                while(v[bound].v) bound--;
            }
        }
    } 
    for(auto p: res){
        cout << p.first << ' ' << p.second << '\n';
    }
}

Submission Info

Submission Time
Task D - Reconstruct Chocolate
User mg00s
Language C++ IOI-Style(GNU++20) (GCC 14.2.0)
Score 0
Code Size 1208 Byte
Status TLE
Exec Time > 2000 ms
Memory 8652 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 425
Status
AC × 2
AC × 13
TLE × 6
Set Name Test Cases
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
Case Name Status Exec Time Memory
00_sample_01.txt AC 0 ms 1580 KiB
00_sample_02.txt AC 0 ms 1580 KiB
01_random_01.txt TLE > 2000 ms 6316 KiB
01_random_02.txt TLE > 2000 ms 6316 KiB
01_random_03.txt AC 1999 ms 8432 KiB
01_random_04.txt TLE > 2000 ms 8400 KiB
01_random_05.txt AC 120 ms 8392 KiB
01_random_06.txt AC 121 ms 8148 KiB
01_random_07.txt TLE > 2000 ms 8652 KiB
01_random_08.txt TLE > 2000 ms 6316 KiB
01_random_09.txt AC 322 ms 8404 KiB
01_random_10.txt AC 324 ms 8404 KiB
01_random_11.txt AC 120 ms 8404 KiB
01_random_12.txt AC 121 ms 8416 KiB
01_random_13.txt AC 330 ms 8404 KiB
01_random_14.txt AC 332 ms 8408 KiB
02_biased_cut_01.txt AC 88 ms 7380 KiB
02_biased_cut_02.txt AC 86 ms 7384 KiB
02_biased_cut_03.txt TLE > 2000 ms 6316 KiB