답안 #349016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
349016 2021-01-16T10:37:12 Z denkendoemeer 무지개나라 (APIO17_rainbow) C++14
100 / 100
1298 ms 79956 KB
#include "rainbow.h"
#include<bits/stdc++.h>
const int inf=1e9;
using namespace std;
vector<vector<int>>dx={{0},{0,1},{0},{0,1}};
vector<vector<int>>dy={{0},{0,1},{0,1},{0}};
struct bit
{
    vector<pair<int,int>>add;
    vector<int>v[200005];
    void init()
    {
        sort(add.begin(),add.end());
        add.resize(unique(add.begin(),add.end())-add.begin());
        int i;
        for(auto it:add)
            for(i=it.first;i<=200000;i=i+(i&-i))
                v[i].push_back(it.second);
        for(i=1;i<=200000;i++)
            sort(v[i].begin(),v[i].end());
    }
    int query(int x,int st,int dr)
    {
        int ans=0;
        for(;x>=1;x=x-(x&-x)){
            auto it1=lower_bound(v[x].begin(),v[x].end(),st);
            auto it2=upper_bound(v[x].begin(),v[x].end(),dr);
            ans=ans+it2-it1;
        }
        return ans;
    }
    int query2(int st,int dr,int l,int r)
    {
        if (st>dr || l>r)
            return 0;
        return query(dr,l,r)-query(st-1,l,r);
    }
}aib[4];
int minr=inf,minc=inf,maxr=-inf,maxc=-inf;
void add(pair<int,int>aux)
{
    minr=min(minr,aux.first);
    maxr=max(maxr,aux.first);
    minc=min(minc,aux.second);
    maxc=max(maxc,aux.second);
    int i;
    for(i=0;i<4;i++)
        for(auto x:dx[i])
            for(auto y:dy[i])
                aib[i].add.push_back(make_pair(aux.first+x,aux.second+y));
}
void init(int r,int c,int sr,int sc,int m,char *s)
{
    pair<int,int>poz;
    poz=make_pair(sr,sc);
    add(poz);
    int i;
    for(i=0;i<m;i++){
        if (s[i]=='N')
            poz.first--;
        if (s[i]=='E')
            poz.second++;
        if (s[i]=='S')
            poz.first++;
        if (s[i]=='W')
            poz.second--;
        add(poz);
    }
    for(i=0;i<4;i++)
        aib[i].init();
}
int colour(int st,int l,int dr,int r)
{
    int nr1=aib[1].query2(st+1,dr,l+1,r),nr2=aib[0].query2(st,dr,l,r),nr3=aib[2].query2(st,dr,l+1,r)+aib[3].query2(st+1,dr,l,r);
    int ans=nr3-nr1-nr2+1;
    if (st<minr && maxr<dr && l<minc && maxc<r)
        ans++;
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 19308 KB Output is correct
2 Correct 21 ms 19712 KB Output is correct
3 Correct 17 ms 19308 KB Output is correct
4 Correct 18 ms 19308 KB Output is correct
5 Correct 23 ms 19820 KB Output is correct
6 Correct 15 ms 19180 KB Output is correct
7 Correct 15 ms 19052 KB Output is correct
8 Correct 15 ms 19180 KB Output is correct
9 Correct 15 ms 19180 KB Output is correct
10 Correct 15 ms 19180 KB Output is correct
11 Correct 18 ms 19564 KB Output is correct
12 Correct 20 ms 19692 KB Output is correct
13 Correct 24 ms 19948 KB Output is correct
14 Correct 25 ms 20352 KB Output is correct
15 Correct 15 ms 19052 KB Output is correct
16 Correct 15 ms 19052 KB Output is correct
17 Correct 15 ms 19196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 19052 KB Output is correct
2 Correct 15 ms 19196 KB Output is correct
3 Correct 540 ms 53900 KB Output is correct
4 Correct 832 ms 79956 KB Output is correct
5 Correct 866 ms 79956 KB Output is correct
6 Correct 703 ms 74196 KB Output is correct
7 Correct 673 ms 68820 KB Output is correct
8 Correct 114 ms 31616 KB Output is correct
9 Correct 736 ms 79956 KB Output is correct
10 Correct 807 ms 79828 KB Output is correct
11 Correct 678 ms 74068 KB Output is correct
12 Correct 840 ms 77268 KB Output is correct
13 Correct 703 ms 79828 KB Output is correct
14 Correct 695 ms 79828 KB Output is correct
15 Correct 617 ms 74196 KB Output is correct
16 Correct 655 ms 71252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 19052 KB Output is correct
2 Correct 413 ms 53460 KB Output is correct
3 Correct 190 ms 57440 KB Output is correct
4 Correct 193 ms 57812 KB Output is correct
5 Correct 210 ms 48212 KB Output is correct
6 Correct 130 ms 32468 KB Output is correct
7 Correct 166 ms 35284 KB Output is correct
8 Correct 524 ms 71300 KB Output is correct
9 Correct 496 ms 67944 KB Output is correct
10 Correct 108 ms 29148 KB Output is correct
11 Correct 213 ms 42068 KB Output is correct
12 Correct 418 ms 53460 KB Output is correct
13 Correct 170 ms 57428 KB Output is correct
14 Correct 193 ms 57812 KB Output is correct
15 Correct 205 ms 48356 KB Output is correct
16 Correct 132 ms 31444 KB Output is correct
17 Correct 191 ms 39124 KB Output is correct
18 Correct 420 ms 67284 KB Output is correct
19 Correct 291 ms 57684 KB Output is correct
20 Correct 342 ms 60500 KB Output is correct
21 Correct 521 ms 71252 KB Output is correct
22 Correct 495 ms 68052 KB Output is correct
23 Correct 108 ms 29020 KB Output is correct
24 Correct 212 ms 42068 KB Output is correct
25 Correct 415 ms 53460 KB Output is correct
26 Correct 170 ms 57428 KB Output is correct
27 Correct 189 ms 57812 KB Output is correct
28 Correct 208 ms 48212 KB Output is correct
29 Correct 129 ms 31444 KB Output is correct
30 Correct 193 ms 39124 KB Output is correct
31 Correct 415 ms 67284 KB Output is correct
32 Correct 297 ms 57684 KB Output is correct
33 Correct 344 ms 60500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 19308 KB Output is correct
2 Correct 21 ms 19712 KB Output is correct
3 Correct 17 ms 19308 KB Output is correct
4 Correct 18 ms 19308 KB Output is correct
5 Correct 23 ms 19820 KB Output is correct
6 Correct 15 ms 19180 KB Output is correct
7 Correct 15 ms 19052 KB Output is correct
8 Correct 15 ms 19180 KB Output is correct
9 Correct 15 ms 19180 KB Output is correct
10 Correct 15 ms 19180 KB Output is correct
11 Correct 18 ms 19564 KB Output is correct
12 Correct 20 ms 19692 KB Output is correct
13 Correct 24 ms 19948 KB Output is correct
14 Correct 25 ms 20352 KB Output is correct
15 Correct 15 ms 19052 KB Output is correct
16 Correct 15 ms 19052 KB Output is correct
17 Correct 15 ms 19196 KB Output is correct
18 Correct 1298 ms 48992 KB Output is correct
19 Correct 297 ms 24044 KB Output is correct
20 Correct 224 ms 22892 KB Output is correct
21 Correct 254 ms 23276 KB Output is correct
22 Correct 276 ms 23288 KB Output is correct
23 Correct 279 ms 24044 KB Output is correct
24 Correct 276 ms 23148 KB Output is correct
25 Correct 287 ms 23404 KB Output is correct
26 Correct 300 ms 23532 KB Output is correct
27 Correct 532 ms 45524 KB Output is correct
28 Correct 401 ms 37460 KB Output is correct
29 Correct 474 ms 42964 KB Output is correct
30 Correct 1093 ms 70740 KB Output is correct
31 Correct 18 ms 19308 KB Output is correct
32 Correct 846 ms 48172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 19308 KB Output is correct
2 Correct 21 ms 19712 KB Output is correct
3 Correct 17 ms 19308 KB Output is correct
4 Correct 18 ms 19308 KB Output is correct
5 Correct 23 ms 19820 KB Output is correct
6 Correct 15 ms 19180 KB Output is correct
7 Correct 15 ms 19052 KB Output is correct
8 Correct 15 ms 19180 KB Output is correct
9 Correct 15 ms 19180 KB Output is correct
10 Correct 15 ms 19180 KB Output is correct
11 Correct 18 ms 19564 KB Output is correct
12 Correct 20 ms 19692 KB Output is correct
13 Correct 24 ms 19948 KB Output is correct
14 Correct 25 ms 20352 KB Output is correct
15 Correct 15 ms 19052 KB Output is correct
16 Correct 15 ms 19052 KB Output is correct
17 Correct 15 ms 19196 KB Output is correct
18 Correct 1298 ms 48992 KB Output is correct
19 Correct 297 ms 24044 KB Output is correct
20 Correct 224 ms 22892 KB Output is correct
21 Correct 254 ms 23276 KB Output is correct
22 Correct 276 ms 23288 KB Output is correct
23 Correct 279 ms 24044 KB Output is correct
24 Correct 276 ms 23148 KB Output is correct
25 Correct 287 ms 23404 KB Output is correct
26 Correct 300 ms 23532 KB Output is correct
27 Correct 532 ms 45524 KB Output is correct
28 Correct 401 ms 37460 KB Output is correct
29 Correct 474 ms 42964 KB Output is correct
30 Correct 1093 ms 70740 KB Output is correct
31 Correct 18 ms 19308 KB Output is correct
32 Correct 846 ms 48172 KB Output is correct
33 Correct 413 ms 53460 KB Output is correct
34 Correct 190 ms 57440 KB Output is correct
35 Correct 193 ms 57812 KB Output is correct
36 Correct 210 ms 48212 KB Output is correct
37 Correct 130 ms 32468 KB Output is correct
38 Correct 166 ms 35284 KB Output is correct
39 Correct 524 ms 71300 KB Output is correct
40 Correct 496 ms 67944 KB Output is correct
41 Correct 108 ms 29148 KB Output is correct
42 Correct 213 ms 42068 KB Output is correct
43 Correct 418 ms 53460 KB Output is correct
44 Correct 170 ms 57428 KB Output is correct
45 Correct 193 ms 57812 KB Output is correct
46 Correct 205 ms 48356 KB Output is correct
47 Correct 132 ms 31444 KB Output is correct
48 Correct 191 ms 39124 KB Output is correct
49 Correct 420 ms 67284 KB Output is correct
50 Correct 291 ms 57684 KB Output is correct
51 Correct 342 ms 60500 KB Output is correct
52 Correct 521 ms 71252 KB Output is correct
53 Correct 495 ms 68052 KB Output is correct
54 Correct 108 ms 29020 KB Output is correct
55 Correct 212 ms 42068 KB Output is correct
56 Correct 415 ms 53460 KB Output is correct
57 Correct 170 ms 57428 KB Output is correct
58 Correct 189 ms 57812 KB Output is correct
59 Correct 208 ms 48212 KB Output is correct
60 Correct 129 ms 31444 KB Output is correct
61 Correct 193 ms 39124 KB Output is correct
62 Correct 415 ms 67284 KB Output is correct
63 Correct 297 ms 57684 KB Output is correct
64 Correct 344 ms 60500 KB Output is correct
65 Correct 910 ms 74864 KB Output is correct
66 Correct 936 ms 71528 KB Output is correct
67 Correct 411 ms 32476 KB Output is correct
68 Correct 550 ms 45524 KB Output is correct
69 Correct 788 ms 56916 KB Output is correct
70 Correct 834 ms 61140 KB Output is correct
71 Correct 642 ms 61268 KB Output is correct
72 Correct 655 ms 51924 KB Output is correct
73 Correct 344 ms 35028 KB Output is correct
74 Correct 448 ms 42580 KB Output is correct
75 Correct 689 ms 70868 KB Output is correct
76 Correct 847 ms 61396 KB Output is correct
77 Correct 685 ms 64084 KB Output is correct
78 Correct 540 ms 53900 KB Output is correct
79 Correct 832 ms 79956 KB Output is correct
80 Correct 866 ms 79956 KB Output is correct
81 Correct 703 ms 74196 KB Output is correct
82 Correct 673 ms 68820 KB Output is correct
83 Correct 114 ms 31616 KB Output is correct
84 Correct 736 ms 79956 KB Output is correct
85 Correct 807 ms 79828 KB Output is correct
86 Correct 678 ms 74068 KB Output is correct
87 Correct 840 ms 77268 KB Output is correct
88 Correct 703 ms 79828 KB Output is correct
89 Correct 695 ms 79828 KB Output is correct
90 Correct 617 ms 74196 KB Output is correct
91 Correct 655 ms 71252 KB Output is correct