Submission #60341469


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int maxn = 2e5 + 7;
const double PI = acos(-1), eps = 1e-7;
int h, w, n;
int ans[maxn];
void solve() {
cin >> h >> w >> n;
vector<vector<pair<int, int>>> a(h + 5, vector<pair<int, int>>(w + 5));
vector<vector<int>>d(h + 5 ,vector<int>(w + 5));
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
a[i][j] = {0, 0};
d[i][j] = h + 1;
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int maxn = 2e5 + 7;
const double PI = acos(-1), eps = 1e-7;

int h, w, n;
int ans[maxn];

void solve() {
    cin >> h >> w >> n;
    vector<vector<pair<int, int>>> a(h + 5, vector<pair<int, int>>(w + 5));
    vector<vector<int>>d(h + 5 ,vector<int>(w + 5));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            a[i][j] = {0, 0};
            d[i][j] = h + 1;
        }
    }
    int x, y, z;
    for (int i = 1; i <= n; i++) {
        cin >> x >> y >> z;
        ans[i] = x;
        a[x][y] = {z, i};
    }
    for (int i = h; i >= 1; i--) {
        for (int j = 1; j <= w; j++) {
            if (a[i][j] != pair<int, int>{0, 0}) {
                int z = h + 1;
                for (int k = j; k <= min(w, j + a[i][j].first - 1); k++) {
                    z = min(z, d[i][k]);
                }
                ans[a[i][j].second] = z - 1;
                for (int k = j; k <= min(w, j + a[i][j].first - 1); k++) {
                    d[i - 1][k] = z - 1;
                }
                j = j + a[i][j].first - 1;
            } else {
                d[i - 1][j] = d[i][j];
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << '\n';
    }
}

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}


/*


 */

Submission Info

Submission Time
Task F - Falling Bars
User 2021404292
Language C++ 20 (gcc 12.2)
Score 0
Code Size 1554 Byte
Status RE
Exec Time 2089 ms
Memory 3629116 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 525
Status
AC × 3
AC × 22
MLE × 2
RE × 28
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.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, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt, 02_handmade_07.txt, 02_handmade_08.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3556 KB
00_sample_01.txt AC 2 ms 4980 KB
00_sample_02.txt AC 1 ms 3516 KB
01_random_00.txt AC 59 ms 26804 KB
01_random_01.txt AC 89 ms 48188 KB
01_random_02.txt AC 158 ms 171056 KB
01_random_03.txt AC 411 ms 568884 KB
01_random_04.txt AC 41 ms 13884 KB
01_random_05.txt RE 1448 ms 3627708 KB
01_random_06.txt AC 233 ms 225984 KB
01_random_07.txt AC 54 ms 27228 KB
01_random_08.txt AC 530 ms 745744 KB
01_random_09.txt AC 109 ms 77880 KB
01_random_10.txt AC 168 ms 141356 KB
01_random_11.txt AC 60 ms 28656 KB
01_random_12.txt AC 44 ms 16188 KB
01_random_13.txt MLE 1556 ms 2416852 KB
01_random_14.txt RE 1370 ms 3627996 KB
01_random_15.txt AC 54 ms 14208 KB
01_random_16.txt AC 207 ms 237060 KB
01_random_17.txt AC 107 ms 61304 KB
01_random_18.txt AC 42 ms 22164 KB
01_random_19.txt MLE 906 ms 1379116 KB
01_random_20.txt RE 1365 ms 3628168 KB
01_random_21.txt RE 1365 ms 3628084 KB
01_random_22.txt RE 1393 ms 3628152 KB
01_random_23.txt RE 1439 ms 3628416 KB
01_random_24.txt RE 1529 ms 3628096 KB
01_random_25.txt RE 1448 ms 3627816 KB
01_random_26.txt RE 1429 ms 3628200 KB
01_random_27.txt RE 1408 ms 3628532 KB
01_random_28.txt RE 1409 ms 3627980 KB
01_random_29.txt RE 1404 ms 3627668 KB
01_random_30.txt RE 1404 ms 3628152 KB
01_random_31.txt RE 1403 ms 3628360 KB
01_random_32.txt RE 1440 ms 3628944 KB
01_random_33.txt RE 1408 ms 3628452 KB
01_random_34.txt RE 1444 ms 3628480 KB
01_random_35.txt RE 1815 ms 3628504 KB
01_random_36.txt RE 1440 ms 3628416 KB
01_random_37.txt RE 1438 ms 3627992 KB
01_random_38.txt RE 1401 ms 3629084 KB
01_random_39.txt RE 1463 ms 3628516 KB
02_handmade_00.txt RE 1441 ms 3629040 KB
02_handmade_01.txt RE 2089 ms 3629052 KB
02_handmade_02.txt RE 1400 ms 3629116 KB
02_handmade_03.txt AC 125 ms 35252 KB
02_handmade_04.txt AC 37 ms 18572 KB
02_handmade_05.txt RE 1446 ms 3628484 KB
02_handmade_06.txt RE 1410 ms 3628908 KB
02_handmade_07.txt RE 1453 ms 3629020 KB
02_handmade_08.txt AC 44 ms 5368 KB


2025-03-22 (Sat)
11:18:10 +00:00