結果
| 問題 |
No.1074 増殖
|
| コンテスト | |
| ユーザー |
LayCurse
|
| 提出日時 | 2020-06-05 21:38:51 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,778 ms / 2,000 ms |
| コード長 | 2,517 bytes |
| コンパイル時間 | 10,415 ms |
| コンパイル使用メモリ | 268,416 KB |
| 最終ジャッジ日時 | 2025-01-10 22:19:19 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
static char buf[1048576];
static int s = 1048576;
static int e = 1048576;
if(s == e && e == 1048576){
e = fread_unlocked(buf, 1, 1048576, stdin);
s = 0;
}
if(s == e){
return EOF;
}
return buf[s++];
}
inline void rd(int &x){
int k;
int m=0;
x=0;
for(;;){
k = my_getchar_unlocked();
if(k=='-'){
m=1;
break;
}
if('0'<=k&&k<='9'){
x=k-'0';
break;
}
}
for(;;){
k = my_getchar_unlocked();
if(k<'0'||k>'9'){
break;
}
x=x*10+k-'0';
}
if(m){
x=-x;
}
}
inline int rd_int(void){
int x;
rd(x);
return x;
}
struct MY_WRITER{
char buf[1048576];
int s;
int e;
MY_WRITER(){
s = 0;
e = 1048576;
}
~MY_WRITER(){
if(s){
fwrite_unlocked(buf, 1, s, stdout);
}
}
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
MY_WRITER_VAR.s = 0;
}
MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
my_putchar_unlocked(a);
}
inline void wt_L(long long x){
int s=0;
int m=0;
char f[20];
if(x<0){
m=1;
x=-x;
}
while(x){
f[s++]=x%10;
x/=10;
}
if(!s){
f[s++]=0;
}
if(m){
my_putchar_unlocked('-');
}
while(s--){
my_putchar_unlocked(f[s]+'0');
}
}
int up[40001];
int dw[40001];
int main(){
int Lj4PdHRW;
int X1;
int Y1;
int X2;
int Y2;
long long res;
int KL2GvlyY = rd_int();
for(Lj4PdHRW=(0);Lj4PdHRW<(KL2GvlyY);Lj4PdHRW++){
int i;
rd(X1);
rd(Y1);
rd(X2);
rd(Y2);
{
auto cTE1_r3A = (20000);
X1 += cTE1_r3A;
X2 += cTE1_r3A;
}
res = 0;
Y1 *= -1;
for(i=(X1);i<(X2);i++){
if(dw[i] < Y1){
res += Y1 - dw[i];
dw[i] = Y1;
}
}
for(i=(X1);i<(X2);i++){
if(up[i] < Y2){
res += Y2 - up[i];
up[i] = Y2;
}
}
wt_L(res);
wt_L('\n');
}
return 0;
}
// cLay varsion 20200509-1
// --- original code ---
// int up[40001], dw[40001];
// {
// int X1, Y1, X2, Y2;
// ll res;
//
// REP(rd_int()){
// rd(X1, Y1, X2, Y2);
// (X1,X2) += 20000;
// res = 0;
// Y1 *= -1;
// rep(i,X1,X2) if(dw[i] < Y1) res += Y1 - dw[i], dw[i] = Y1;
// rep(i,X1,X2) if(up[i] < Y2) res += Y2 - up[i], up[i] = Y2;
// wt(res);
// }
//
// }
LayCurse