結果

問題 No.1338 Giant Class
ユーザー iiljj
提出日時 2021-01-15 23:04:41
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,080 bytes
コンパイル時間 1,919 ms
コンパイル使用メモリ 73,984 KB
最終ジャッジ日時 2025-01-17 20:23:21
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 3 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#include <map>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>

// clang-format off
#define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}
#define WT(var,buf,ptr) long v=var;ptr=0;while(v){buf[ptr++]=v%10;v/=10;}while(ptr--){*wp++=buf[ptr]+'0';}*wp++='\n';
// clang-format on

int y[100000];
int x[100000];
char wbuf[100000 * 21];

int main() {
    char *rp = (char *)mmap(0l, 1l << 28, 1, 2, 0, 0ll);
    char *wp = wbuf;
    RD(h) RD(w) RD(q);
    int *xp = x, *yp = y;
    for (int i = 0; i < q; ++i) {
        RD(yy) RD(xx);
        *yp++ = --yy;
        *xp++ = --xx;
    }
    std::map<int, int> mp;
    xp = x, yp = y;
    long prod = (long)h * w;
    char buf[9];
    int ptr;
    for (int i = 0; i < q; ++i) {
        int mi = (mp.count(*xp)) ? mp[*xp] : h; //
        if (*yp < mi) {
            prod -= (mi - *yp);
            mp[*xp] = *yp;
        }
        xp++, yp++; //
        WT(prod, buf, ptr);
    }
    write(1, wbuf, (wp - wbuf) * sizeof(*wbuf));
    exit(0);
    return 0;
}
0