Submission #475936

# Submission time Handle Problem Language Result Execution time Memory
475936 2021-09-24T13:23:32 Z qwerasdfzxcl Navigation 2 (JOI21_navigation2) C++17
100 / 100
871 ms 1008 KB
#include "Anna.h"
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

namespace {



} // namespace

void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
    bool chk[9];
    fill(chk, chk+9, 0);
    for (int i=0;i<K;i++){
        int num = (R[i]*3+C[i]+1)%9;
        chk[((i+10)-num)%9] = 1;
    }

    int typ = -1;
    for (int i=0;i<9;i++) if (!chk[i]) {typ = i; break;}
    assert(typ!=-1);

    fill(chk, chk+9, 0);

    for (int i=0;i<N;i++){
        for (int j=0;j<N;j++){
            int num = (i*3+j+typ+1)%9;
            if (!num) SetFlag(i, j, 12);
            else if (num==8) continue; //SetFlag(i, j, 1);
            else{
                num--;
                if (R[num]<i-1) SetFlag(i, j, 4);
                else if (R[num]>i+1) SetFlag(i, j, 3);
                else if (C[num]<j-1) SetFlag(i, j, 2);
                else if (C[num]>j+1) SetFlag(i, j, 1);
                else{
                    for (int x=-1, val=5;x<=1;x++){
                        for (int y=-1;y<=1;y++) if (x || y){
                            if (i+x==R[num] && j+y==C[num]){
                                chk[val-5] = 1;
                            }
                            val++;
                        }
                    }
                }
            }
        }
    }

    int typ2 = -1;
    for (int i=0;i<8;i++) if (!chk[i]) {typ2 = i; break;}
    assert(typ2!=-1);

    for (int i=0;i<N;i++){
        for (int j=0;j<N;j++){
            int num = (i*3+j+typ+1)%9;
            if (!num) continue;
            else if (num==8) SetFlag(i, j, typ2+1);
            else{
                num--;
                if (R[num]<i-1) continue;
                else if (R[num]>i+1) continue;
                else if (C[num]<j-1) continue;
                else if (C[num]>j+1) continue;
                else{
                    for (int x=-1, val=5;x<=1;x++){
                        for (int y=-1;y<=1;y++) if (x || y){
                            if (i+x==R[num] && j+y==C[num]){
                                if (val>typ2+5) val--;
                                SetFlag(i, j, val);
                            }
                            val++;
                        }
                    }
                }
            }
        }
    }
}
#include "Bruno.h"
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

namespace {


} // namespace

std::vector<int> Bruno(int K, std::vector<int> value) {
    vector<int> ret(7);
    int pivot = -1;
    for (int i=0;i<9;i++) if (value[i]==12) pivot = i;
    assert(pivot!=-1);

    int typ2 = -1;
    for (int i=-1, k=0;i<=1;i++){
        for (int j=-1;j<=1;j++, k++){
            int num = 0;
            num += (i-pivot/3+1)*3 + (j-pivot%3+1);
            num = (num+90)%9;
            if (num==8) typ2 = value[k];
        }
    }
    typ2--;
    assert(typ2!=-1);

    for (int i=-1, k=0;i<=1;i++){
        for (int j=-1;j<=1;j++, k++){
            int num = 0;
            num += (i-pivot/3+1)*3 + (j-pivot%3+1);
            num = (num+90)%9;
            if (num==0 || num==8) continue;
            num--;
            if (value[k]<=4) ret[num] = value[k]-1;
            else{
                if (value[k]>=typ2+5) value[k]++;
                int ex = -1e9, ey = -1e9;
                for (int x=-1, val=5;x<=1;x++){
                    for (int y=-1;y<=1;y++) if (x || y){
                        if (value[k]==val) ex = i+x, ey = j+y;
                        val++;
                    }
                }
                assert(ex!=-1e9 && ey!=-1e9);
                if (ex<0) ret[num] = 3;
                else if (ex>0) ret[num] = 2;
                else if (ey<0) ret[num] = 1;
                else if (ey>0) ret[num] = 0;
                else ret[num] = 4;
            }
        }
    }
    return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 384 KB Output is correct
2 Correct 11 ms 384 KB Output is correct
3 Correct 12 ms 384 KB Output is correct
4 Correct 12 ms 388 KB Output is correct
5 Correct 13 ms 384 KB Output is correct
6 Correct 14 ms 388 KB Output is correct
7 Correct 12 ms 384 KB Output is correct
8 Correct 16 ms 384 KB Output is correct
9 Correct 15 ms 384 KB Output is correct
10 Correct 14 ms 476 KB Output is correct
11 Correct 12 ms 384 KB Output is correct
12 Correct 12 ms 384 KB Output is correct
13 Correct 13 ms 388 KB Output is correct
14 Correct 13 ms 384 KB Output is correct
15 Correct 12 ms 388 KB Output is correct
16 Correct 16 ms 448 KB Output is correct
17 Correct 13 ms 388 KB Output is correct
18 Correct 10 ms 384 KB Output is correct
19 Correct 14 ms 388 KB Output is correct
20 Correct 13 ms 384 KB Output is correct
21 Correct 13 ms 384 KB Output is correct
22 Correct 12 ms 388 KB Output is correct
23 Correct 12 ms 388 KB Output is correct
24 Correct 12 ms 384 KB Output is correct
25 Correct 14 ms 384 KB Output is correct
26 Correct 13 ms 388 KB Output is correct
27 Correct 16 ms 384 KB Output is correct
28 Correct 13 ms 388 KB Output is correct
29 Correct 13 ms 384 KB Output is correct
30 Correct 17 ms 392 KB Output is correct
31 Correct 16 ms 392 KB Output is correct
32 Correct 11 ms 464 KB Output is correct
33 Correct 14 ms 384 KB Output is correct
34 Correct 14 ms 384 KB Output is correct
35 Correct 12 ms 384 KB Output is correct
36 Correct 14 ms 384 KB Output is correct
37 Correct 15 ms 384 KB Output is correct
38 Correct 18 ms 388 KB Output is correct
39 Correct 15 ms 384 KB Output is correct
40 Correct 16 ms 384 KB Output is correct
41 Correct 16 ms 384 KB Output is correct
42 Correct 14 ms 384 KB Output is correct
43 Correct 14 ms 388 KB Output is correct
44 Correct 14 ms 384 KB Output is correct
45 Correct 13 ms 388 KB Output is correct
46 Correct 16 ms 384 KB Output is correct
47 Correct 17 ms 512 KB Output is correct
48 Correct 18 ms 384 KB Output is correct
49 Correct 19 ms 384 KB Output is correct
50 Correct 16 ms 384 KB Output is correct
51 Correct 17 ms 384 KB Output is correct
52 Correct 17 ms 384 KB Output is correct
53 Correct 15 ms 388 KB Output is correct
54 Correct 19 ms 384 KB Output is correct
55 Correct 13 ms 384 KB Output is correct
56 Correct 15 ms 384 KB Output is correct
57 Correct 22 ms 384 KB Output is correct
58 Correct 23 ms 404 KB Output is correct
59 Correct 18 ms 384 KB Output is correct
60 Correct 19 ms 384 KB Output is correct
61 Correct 23 ms 384 KB Output is correct
62 Correct 24 ms 384 KB Output is correct
63 Correct 18 ms 512 KB Output is correct
64 Correct 19 ms 384 KB Output is correct
65 Correct 17 ms 468 KB Output is correct
66 Correct 19 ms 472 KB Output is correct
67 Correct 18 ms 384 KB Output is correct
68 Correct 25 ms 384 KB Output is correct
69 Correct 19 ms 384 KB Output is correct
70 Correct 18 ms 384 KB Output is correct
71 Correct 17 ms 384 KB Output is correct
72 Correct 19 ms 384 KB Output is correct
73 Correct 20 ms 384 KB Output is correct
74 Correct 24 ms 388 KB Output is correct
75 Correct 22 ms 384 KB Output is correct
76 Correct 17 ms 384 KB Output is correct
77 Correct 17 ms 388 KB Output is correct
78 Correct 19 ms 384 KB Output is correct
79 Correct 17 ms 384 KB Output is correct
80 Correct 24 ms 384 KB Output is correct
81 Correct 26 ms 384 KB Output is correct
82 Correct 17 ms 468 KB Output is correct
83 Correct 24 ms 384 KB Output is correct
84 Correct 19 ms 388 KB Output is correct
85 Correct 24 ms 384 KB Output is correct
86 Correct 23 ms 388 KB Output is correct
87 Correct 17 ms 384 KB Output is correct
88 Correct 18 ms 384 KB Output is correct
89 Correct 18 ms 388 KB Output is correct
90 Correct 24 ms 384 KB Output is correct
91 Correct 18 ms 384 KB Output is correct
92 Correct 18 ms 384 KB Output is correct
93 Correct 20 ms 384 KB Output is correct
94 Correct 18 ms 384 KB Output is correct
95 Correct 16 ms 388 KB Output is correct
96 Correct 22 ms 384 KB Output is correct
97 Correct 19 ms 384 KB Output is correct
98 Correct 22 ms 384 KB Output is correct
99 Correct 18 ms 384 KB Output is correct
100 Correct 19 ms 384 KB Output is correct
101 Correct 17 ms 384 KB Output is correct
102 Correct 18 ms 384 KB Output is correct
103 Correct 19 ms 384 KB Output is correct
104 Correct 17 ms 384 KB Output is correct
105 Correct 17 ms 384 KB Output is correct
106 Correct 19 ms 384 KB Output is correct
107 Correct 18 ms 384 KB Output is correct
108 Correct 18 ms 384 KB Output is correct
109 Correct 19 ms 384 KB Output is correct
110 Correct 17 ms 384 KB Output is correct
111 Correct 23 ms 384 KB Output is correct
112 Correct 16 ms 460 KB Output is correct
113 Correct 18 ms 384 KB Output is correct
114 Correct 19 ms 384 KB Output is correct
115 Correct 18 ms 384 KB Output is correct
116 Correct 15 ms 384 KB Output is correct
117 Correct 17 ms 384 KB Output is correct
118 Correct 16 ms 384 KB Output is correct
119 Correct 17 ms 388 KB Output is correct
120 Correct 636 ms 596 KB Output is correct
121 Correct 657 ms 564 KB Output is correct
122 Correct 640 ms 620 KB Output is correct
123 Correct 725 ms 592 KB Output is correct
124 Correct 681 ms 796 KB Output is correct
125 Correct 744 ms 600 KB Output is correct
126 Correct 679 ms 692 KB Output is correct
127 Correct 671 ms 704 KB Output is correct
128 Correct 700 ms 512 KB Output is correct
129 Correct 710 ms 712 KB Output is correct
130 Correct 662 ms 648 KB Output is correct
131 Correct 630 ms 596 KB Output is correct
132 Correct 683 ms 800 KB Output is correct
133 Correct 638 ms 664 KB Output is correct
134 Correct 689 ms 644 KB Output is correct
135 Correct 652 ms 688 KB Output is correct
136 Correct 680 ms 640 KB Output is correct
137 Correct 718 ms 636 KB Output is correct
138 Correct 645 ms 648 KB Output is correct
139 Correct 765 ms 604 KB Output is correct
140 Correct 713 ms 608 KB Output is correct
141 Correct 660 ms 496 KB Output is correct
142 Correct 772 ms 572 KB Output is correct
143 Correct 680 ms 560 KB Output is correct
144 Correct 683 ms 652 KB Output is correct
145 Correct 642 ms 700 KB Output is correct
146 Correct 708 ms 632 KB Output is correct
147 Correct 699 ms 688 KB Output is correct
148 Correct 685 ms 732 KB Output is correct
149 Correct 653 ms 592 KB Output is correct
150 Correct 703 ms 624 KB Output is correct
151 Correct 705 ms 652 KB Output is correct
152 Correct 687 ms 548 KB Output is correct
153 Correct 630 ms 808 KB Output is correct
154 Correct 688 ms 648 KB Output is correct
155 Correct 696 ms 696 KB Output is correct
156 Correct 713 ms 616 KB Output is correct
157 Correct 769 ms 664 KB Output is correct
158 Correct 736 ms 676 KB Output is correct
159 Correct 680 ms 576 KB Output is correct
160 Correct 768 ms 596 KB Output is correct
161 Correct 727 ms 684 KB Output is correct
162 Correct 661 ms 632 KB Output is correct
163 Correct 661 ms 596 KB Output is correct
164 Correct 721 ms 1008 KB Output is correct
165 Correct 706 ms 788 KB Output is correct
166 Correct 690 ms 716 KB Output is correct
167 Correct 778 ms 704 KB Output is correct
168 Correct 731 ms 548 KB Output is correct
169 Correct 694 ms 516 KB Output is correct
170 Correct 688 ms 608 KB Output is correct
171 Correct 720 ms 580 KB Output is correct
172 Correct 703 ms 576 KB Output is correct
173 Correct 699 ms 592 KB Output is correct
174 Correct 767 ms 552 KB Output is correct
175 Correct 719 ms 632 KB Output is correct
176 Correct 871 ms 512 KB Output is correct
177 Correct 726 ms 648 KB Output is correct
178 Correct 694 ms 612 KB Output is correct
179 Correct 745 ms 640 KB Output is correct
180 Correct 713 ms 664 KB Output is correct
181 Correct 687 ms 644 KB Output is correct
182 Correct 660 ms 616 KB Output is correct
183 Correct 692 ms 640 KB Output is correct
184 Correct 720 ms 604 KB Output is correct
185 Correct 658 ms 696 KB Output is correct
186 Correct 768 ms 504 KB Output is correct
187 Correct 688 ms 584 KB Output is correct
188 Correct 674 ms 796 KB Output is correct
189 Correct 685 ms 596 KB Output is correct
190 Correct 703 ms 496 KB Output is correct
191 Correct 779 ms 592 KB Output is correct
192 Correct 656 ms 616 KB Output is correct
193 Correct 692 ms 680 KB Output is correct
194 Correct 680 ms 612 KB Output is correct
195 Correct 688 ms 712 KB Output is correct
196 Correct 685 ms 576 KB Output is correct
197 Correct 826 ms 748 KB Output is correct
198 Correct 733 ms 580 KB Output is correct
199 Correct 721 ms 568 KB Output is correct
200 Correct 661 ms 700 KB Output is correct
201 Correct 663 ms 712 KB Output is correct
202 Correct 680 ms 848 KB Output is correct
203 Correct 768 ms 804 KB Output is correct
204 Correct 699 ms 512 KB Output is correct
205 Correct 682 ms 672 KB Output is correct
206 Correct 654 ms 560 KB Output is correct
207 Correct 705 ms 572 KB Output is correct
208 Correct 699 ms 652 KB Output is correct
209 Correct 776 ms 656 KB Output is correct
210 Correct 499 ms 656 KB Output is correct
211 Correct 559 ms 664 KB Output is correct
212 Correct 489 ms 780 KB Output is correct
213 Correct 499 ms 644 KB Output is correct
214 Correct 494 ms 488 KB Output is correct
215 Correct 507 ms 592 KB Output is correct
216 Correct 574 ms 492 KB Output is correct
217 Correct 502 ms 540 KB Output is correct
218 Correct 488 ms 696 KB Output is correct
219 Correct 482 ms 608 KB Output is correct
220 Correct 514 ms 636 KB Output is correct
221 Correct 542 ms 616 KB Output is correct
222 Correct 542 ms 700 KB Output is correct
223 Correct 520 ms 700 KB Output is correct
224 Correct 512 ms 780 KB Output is correct
225 Correct 545 ms 728 KB Output is correct
226 Correct 475 ms 632 KB Output is correct