提出 #577690


ソースコード 拡げる

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>          //cout<<fixed<<setprecision(10);
//#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
//#include <memory.h>
#include <cassert>

#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) ((int)strlen(X))
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0)
#ifdef ONLINE_JUDGE
#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#else
#define FILEIO(name)
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
/*#include<complex>
typedef complex<double> cd;
#define X real()
#define Y imag()*/

struct node{
    int l,r;
    node *lp,*rp;
    int u,v;
    bool mark;
}nodepool[10000000],*ntp;

node* newnode(){
    ntp->u=ntp->v=0;
    ntp->lp=ntp->rp=NULL;
    ntp->l=ntp->r=0;
    ntp->mark=false;
    return ntp++;
}

void build(node *&x,int L,int R){
    x->l=L;
    x->r=R;
    if(L<R){
        int M=(L+R)/2;
        x->lp=newnode();
        x->rp=newnode();
        build(x->lp,L,M);
        build(x->rp,M+1,R);
    }
}

void mk(node *x,int U,int V){
    if(x->mark){
        if(x->v==U)x->v=V;
        else x->v=-1;
    }
    else{
        x->mark=1;
        x->u=U;
        x->v=V;
    }
}

void go(node *x,int L,int R,int X){
    if(L>x->r||R<x->l)return;
    else if(L<=x->l&&R>=x->r){
        mk(x,X-1,X);
        return;
    }
    else{
        if(x->mark){
            x->mark=0;
            mk(x->lp,x->u,x->v);
            mk(x->rp,x->u,x->v);
        }
        go(x->lp,L,R,X);
        go(x->rp,L,R,X);
    }
}

int ans=0;
void fuck(node *x,int k){
    if(x->l!=x->r){
        if(x->mark){
            x->mark=0;
            mk(x->lp,x->u,x->v);
            mk(x->rp,x->u,x->v);
        }
        fuck(x->lp,k);
        fuck(x->rp,k);
    }
    else{
        if(x->u==0&&x->v==k)ans++;
    }
}

int main()
{
    ntp=nodepool;
    node *root=newnode();
    DRII(n,k);
    build(root,1,n);
    root->mark=1;
    DRI(T);
    int L,R,X;
    while(T--){
        RIII(L,R,X);
        go(root,L,R,X);
    }
    fuck(root,k);
    cout<<ans<<endl;
    return 0;
}

提出情報

提出日時
問題 H - Donut Decoration
ユーザ HDYTTO
言語 C++11 (GCC 4.8.1)
得点 100
コード長 3185 Byte
結果 AC
実行時間 398 ms
メモリ 16576 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:138:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     DRII(n,k);
              ^
./Main.cpp:141:11: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     DRI(T);
           ^
./Main.cpp:144:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         RIII(L,R,X);
                    ^

ジャッジ結果

セット名 All
得点 / 配点 100 / 100
結果
AC × 33
セット名 テストケース
All 00_sample_00, 00_sample_01, 00_sample_02, 10_random_small_000, 10_random_small_001, 10_random_small_002, 10_random_small_003, 10_random_small_004, 10_random_small_005, 10_random_small_006, 10_random_small_007, 10_random_small_008, 10_random_small_009, 20_random_large_000, 20_random_large_001, 20_random_large_002, 20_random_large_003, 20_random_large_004, 20_random_large_005, 20_random_large_006, 20_random_large_007, 20_random_large_008, 20_random_large_009, 30_update_widely_000, 30_update_widely_001, 30_update_widely_002, 30_update_widely_003, 40_comb_pattern_000, 40_comb_pattern_001, 41_random_split_000, 41_random_split_001, 90_challenge_00, 90_challenge_01
ケース名 結果 実行時間 メモリ
00_sample_00 AC 58 ms 936 KiB
00_sample_01 AC 26 ms 948 KiB
00_sample_02 AC 26 ms 1044 KiB
10_random_small_000 AC 27 ms 1044 KiB
10_random_small_001 AC 26 ms 1044 KiB
10_random_small_002 AC 26 ms 1044 KiB
10_random_small_003 AC 26 ms 1044 KiB
10_random_small_004 AC 27 ms 860 KiB
10_random_small_005 AC 26 ms 1040 KiB
10_random_small_006 AC 26 ms 1044 KiB
10_random_small_007 AC 27 ms 1032 KiB
10_random_small_008 AC 24 ms 1048 KiB
10_random_small_009 AC 26 ms 880 KiB
20_random_large_000 AC 390 ms 16568 KiB
20_random_large_001 AC 398 ms 16560 KiB
20_random_large_002 AC 391 ms 16576 KiB
20_random_large_003 AC 393 ms 16472 KiB
20_random_large_004 AC 390 ms 16576 KiB
20_random_large_005 AC 393 ms 16488 KiB
20_random_large_006 AC 387 ms 16564 KiB
20_random_large_007 AC 385 ms 16564 KiB
20_random_large_008 AC 397 ms 16488 KiB
20_random_large_009 AC 393 ms 16488 KiB
30_update_widely_000 AC 112 ms 948 KiB
30_update_widely_001 AC 116 ms 1044 KiB
30_update_widely_002 AC 143 ms 6068 KiB
30_update_widely_003 AC 173 ms 16568 KiB
40_comb_pattern_000 AC 100 ms 948 KiB
40_comb_pattern_001 AC 154 ms 16564 KiB
41_random_split_000 AC 143 ms 1052 KiB
41_random_split_001 AC 239 ms 16564 KiB
90_challenge_00 AC 213 ms 16568 KiB
90_challenge_01 AC 198 ms 16564 KiB