Submission #930105

# Submission time Handle Problem Language Result Execution time Memory
930105 2024-02-18T13:50:05 Z bachhoangxuan Navigation 2 (JOI21_navigation2) C++17
100 / 100
563 ms 2448 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

namespace A{
    const int Col = 13;
    const int maxn = 105;
    int flag[maxn][maxn];

    void solve(int N,int K,vector<int> R,vector<int> C){
        function<int(int,int,int,int)> g = [&](int i,int j,int x,int y){
            if(j<=y-2) return 9;
            if(j>=y+2) return 10;
            if(i<=x-2) return 11;
            if(i>=x+2) return 12;
            int val=(i-x+1)*3+j-y+1+1;
            return (val==9?-1:val);
        };
        function<bool(int)> f = [&](int d){
            for(int i=0;i<N;i++) for(int j=0;j<N;j++){
                int k=(i+(d/3))%3*3+(j+d%3)%3;
                flag[i][j]=(k<7?g(i,j,R[k],C[k]):(k==8?Col:0));
                if(flag[i][j]==-1) return false;
            }
            return true;
        };
        for(int i=0;i<9;i++) if(f(i)) break;
        vector<bool> used(Col+1,0);
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++) used[flag[i][j]]=true;
        }
        int x=0;
        while(used[x]) x++;
        for(int i=0;i<N;i++) for(int j=0;j<N;j++){
            if(flag[i][j]>x) flag[i][j]--;
            if(flag[i][j]==0) flag[i][j]=x;
            SetFlag(i,j,flag[i][j]);
        }
    }
}

void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
    A::solve(N,K,R,C);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;

namespace B{
    const int Col = 12;
    vector<int> solve(int K,vector<int> value){
        vector<int> res(K,0);
        int dx=-1,dy=-1;
        for(int i=0;i<9;i++) if(value[i]==Col){
            dx=i/3,dy=i%3;
            break;
        }
        int X=value[dx*3+(dy+2)%3];
        function<int(int,int,int,int)> f = [&](int i,int j,int x,int y){
            if(j<y) return 0;
            if(j>y) return 1;
            if(i<x) return 2;
            if(i>x) return 3;
            return 4;
        };
        for(int d=0;d<9;d++){
            int i=(d/3+2-dx)%3,j=(d%3+2-dy)%3;
            int k=i*3+j;
            if(k>=7) continue;
            if(value[d]>=X) value[d]++;
            if(value[d]>=9) res[k]=value[d]-9;
            else{
                int x=d/3+(1-(value[d]-1)/3),y=d%3+(1-(value[d]-1)%3);
                res[k]=f(1,1,x,y);
            }
        }
        return res;
    }
}

std::vector<int> Bruno(int K, std::vector<int> value) {
    return B::solve(K,value);
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 664 KB Output is correct
2 Correct 8 ms 664 KB Output is correct
3 Correct 7 ms 664 KB Output is correct
4 Correct 6 ms 744 KB Output is correct
5 Correct 9 ms 920 KB Output is correct
6 Correct 8 ms 672 KB Output is correct
7 Correct 9 ms 664 KB Output is correct
8 Correct 7 ms 664 KB Output is correct
9 Correct 9 ms 1416 KB Output is correct
10 Correct 9 ms 664 KB Output is correct
11 Correct 7 ms 920 KB Output is correct
12 Correct 7 ms 664 KB Output is correct
13 Correct 9 ms 920 KB Output is correct
14 Correct 7 ms 920 KB Output is correct
15 Correct 9 ms 664 KB Output is correct
16 Correct 9 ms 920 KB Output is correct
17 Correct 8 ms 664 KB Output is correct
18 Correct 7 ms 920 KB Output is correct
19 Correct 7 ms 920 KB Output is correct
20 Correct 7 ms 920 KB Output is correct
21 Correct 10 ms 920 KB Output is correct
22 Correct 7 ms 920 KB Output is correct
23 Correct 9 ms 664 KB Output is correct
24 Correct 9 ms 920 KB Output is correct
25 Correct 7 ms 1176 KB Output is correct
26 Correct 8 ms 920 KB Output is correct
27 Correct 9 ms 664 KB Output is correct
28 Correct 8 ms 920 KB Output is correct
29 Correct 11 ms 1092 KB Output is correct
30 Correct 9 ms 920 KB Output is correct
31 Correct 7 ms 1176 KB Output is correct
32 Correct 9 ms 664 KB Output is correct
33 Correct 8 ms 920 KB Output is correct
34 Correct 7 ms 920 KB Output is correct
35 Correct 9 ms 924 KB Output is correct
36 Correct 8 ms 664 KB Output is correct
37 Correct 9 ms 920 KB Output is correct
38 Correct 8 ms 1176 KB Output is correct
39 Correct 10 ms 920 KB Output is correct
40 Correct 10 ms 668 KB Output is correct
41 Correct 7 ms 920 KB Output is correct
42 Correct 10 ms 920 KB Output is correct
43 Correct 10 ms 664 KB Output is correct
44 Correct 8 ms 920 KB Output is correct
45 Correct 10 ms 920 KB Output is correct
46 Correct 11 ms 920 KB Output is correct
47 Correct 10 ms 924 KB Output is correct
48 Correct 11 ms 668 KB Output is correct
49 Correct 10 ms 928 KB Output is correct
50 Correct 8 ms 920 KB Output is correct
51 Correct 11 ms 920 KB Output is correct
52 Correct 10 ms 920 KB Output is correct
53 Correct 11 ms 920 KB Output is correct
54 Correct 11 ms 1172 KB Output is correct
55 Correct 10 ms 920 KB Output is correct
56 Correct 12 ms 1004 KB Output is correct
57 Correct 10 ms 1168 KB Output is correct
58 Correct 13 ms 664 KB Output is correct
59 Correct 11 ms 920 KB Output is correct
60 Correct 13 ms 920 KB Output is correct
61 Correct 12 ms 664 KB Output is correct
62 Correct 10 ms 920 KB Output is correct
63 Correct 12 ms 664 KB Output is correct
64 Correct 12 ms 920 KB Output is correct
65 Correct 14 ms 920 KB Output is correct
66 Correct 13 ms 920 KB Output is correct
67 Correct 13 ms 664 KB Output is correct
68 Correct 13 ms 664 KB Output is correct
69 Correct 12 ms 1100 KB Output is correct
70 Correct 12 ms 920 KB Output is correct
71 Correct 12 ms 1172 KB Output is correct
72 Correct 14 ms 920 KB Output is correct
73 Correct 10 ms 664 KB Output is correct
74 Correct 12 ms 664 KB Output is correct
75 Correct 11 ms 920 KB Output is correct
76 Correct 12 ms 920 KB Output is correct
77 Correct 13 ms 748 KB Output is correct
78 Correct 11 ms 664 KB Output is correct
79 Correct 11 ms 920 KB Output is correct
80 Correct 12 ms 664 KB Output is correct
81 Correct 13 ms 664 KB Output is correct
82 Correct 13 ms 920 KB Output is correct
83 Correct 12 ms 920 KB Output is correct
84 Correct 12 ms 664 KB Output is correct
85 Correct 12 ms 920 KB Output is correct
86 Correct 12 ms 1172 KB Output is correct
87 Correct 12 ms 920 KB Output is correct
88 Correct 10 ms 920 KB Output is correct
89 Correct 13 ms 920 KB Output is correct
90 Correct 14 ms 664 KB Output is correct
91 Correct 11 ms 664 KB Output is correct
92 Correct 13 ms 844 KB Output is correct
93 Correct 14 ms 664 KB Output is correct
94 Correct 10 ms 920 KB Output is correct
95 Correct 13 ms 664 KB Output is correct
96 Correct 12 ms 1176 KB Output is correct
97 Correct 13 ms 920 KB Output is correct
98 Correct 13 ms 920 KB Output is correct
99 Correct 13 ms 920 KB Output is correct
100 Correct 13 ms 920 KB Output is correct
101 Correct 10 ms 664 KB Output is correct
102 Correct 10 ms 920 KB Output is correct
103 Correct 12 ms 920 KB Output is correct
104 Correct 10 ms 664 KB Output is correct
105 Correct 11 ms 1172 KB Output is correct
106 Correct 13 ms 920 KB Output is correct
107 Correct 11 ms 920 KB Output is correct
108 Correct 12 ms 664 KB Output is correct
109 Correct 12 ms 920 KB Output is correct
110 Correct 12 ms 664 KB Output is correct
111 Correct 12 ms 664 KB Output is correct
112 Correct 14 ms 920 KB Output is correct
113 Correct 11 ms 1172 KB Output is correct
114 Correct 12 ms 832 KB Output is correct
115 Correct 13 ms 920 KB Output is correct
116 Correct 12 ms 920 KB Output is correct
117 Correct 12 ms 920 KB Output is correct
118 Correct 13 ms 920 KB Output is correct
119 Correct 10 ms 664 KB Output is correct
120 Correct 541 ms 1716 KB Output is correct
121 Correct 476 ms 2020 KB Output is correct
122 Correct 476 ms 1624 KB Output is correct
123 Correct 514 ms 2024 KB Output is correct
124 Correct 513 ms 1876 KB Output is correct
125 Correct 541 ms 1484 KB Output is correct
126 Correct 470 ms 2092 KB Output is correct
127 Correct 499 ms 2160 KB Output is correct
128 Correct 480 ms 1972 KB Output is correct
129 Correct 513 ms 1784 KB Output is correct
130 Correct 539 ms 2048 KB Output is correct
131 Correct 517 ms 1492 KB Output is correct
132 Correct 521 ms 2040 KB Output is correct
133 Correct 493 ms 2128 KB Output is correct
134 Correct 506 ms 1880 KB Output is correct
135 Correct 482 ms 1628 KB Output is correct
136 Correct 519 ms 1668 KB Output is correct
137 Correct 496 ms 1968 KB Output is correct
138 Correct 512 ms 2192 KB Output is correct
139 Correct 520 ms 1720 KB Output is correct
140 Correct 487 ms 1660 KB Output is correct
141 Correct 489 ms 1896 KB Output is correct
142 Correct 502 ms 1372 KB Output is correct
143 Correct 516 ms 1688 KB Output is correct
144 Correct 502 ms 1612 KB Output is correct
145 Correct 490 ms 1872 KB Output is correct
146 Correct 494 ms 1400 KB Output is correct
147 Correct 520 ms 2304 KB Output is correct
148 Correct 480 ms 1432 KB Output is correct
149 Correct 481 ms 1928 KB Output is correct
150 Correct 515 ms 2024 KB Output is correct
151 Correct 511 ms 2200 KB Output is correct
152 Correct 516 ms 1288 KB Output is correct
153 Correct 542 ms 1660 KB Output is correct
154 Correct 488 ms 1528 KB Output is correct
155 Correct 490 ms 1832 KB Output is correct
156 Correct 482 ms 1888 KB Output is correct
157 Correct 563 ms 1984 KB Output is correct
158 Correct 500 ms 1872 KB Output is correct
159 Correct 491 ms 2344 KB Output is correct
160 Correct 496 ms 2064 KB Output is correct
161 Correct 503 ms 1780 KB Output is correct
162 Correct 515 ms 2036 KB Output is correct
163 Correct 514 ms 1960 KB Output is correct
164 Correct 474 ms 1912 KB Output is correct
165 Correct 465 ms 2188 KB Output is correct
166 Correct 539 ms 1656 KB Output is correct
167 Correct 497 ms 2252 KB Output is correct
168 Correct 544 ms 1548 KB Output is correct
169 Correct 496 ms 2080 KB Output is correct
170 Correct 546 ms 1936 KB Output is correct
171 Correct 473 ms 2276 KB Output is correct
172 Correct 508 ms 2268 KB Output is correct
173 Correct 508 ms 1916 KB Output is correct
174 Correct 494 ms 1944 KB Output is correct
175 Correct 484 ms 2056 KB Output is correct
176 Correct 472 ms 2124 KB Output is correct
177 Correct 482 ms 1924 KB Output is correct
178 Correct 492 ms 1640 KB Output is correct
179 Correct 514 ms 1852 KB Output is correct
180 Correct 509 ms 2104 KB Output is correct
181 Correct 488 ms 1632 KB Output is correct
182 Correct 484 ms 1828 KB Output is correct
183 Correct 469 ms 1896 KB Output is correct
184 Correct 547 ms 1804 KB Output is correct
185 Correct 476 ms 2448 KB Output is correct
186 Correct 528 ms 2144 KB Output is correct
187 Correct 482 ms 1720 KB Output is correct
188 Correct 526 ms 2144 KB Output is correct
189 Correct 468 ms 2252 KB Output is correct
190 Correct 492 ms 1652 KB Output is correct
191 Correct 470 ms 1856 KB Output is correct
192 Correct 507 ms 2020 KB Output is correct
193 Correct 483 ms 1872 KB Output is correct
194 Correct 536 ms 1784 KB Output is correct
195 Correct 523 ms 1984 KB Output is correct
196 Correct 532 ms 1880 KB Output is correct
197 Correct 496 ms 2084 KB Output is correct
198 Correct 498 ms 2176 KB Output is correct
199 Correct 479 ms 1928 KB Output is correct
200 Correct 473 ms 2408 KB Output is correct
201 Correct 492 ms 1956 KB Output is correct
202 Correct 474 ms 2016 KB Output is correct
203 Correct 538 ms 1908 KB Output is correct
204 Correct 534 ms 1776 KB Output is correct
205 Correct 517 ms 2084 KB Output is correct
206 Correct 508 ms 1460 KB Output is correct
207 Correct 536 ms 1976 KB Output is correct
208 Correct 499 ms 2160 KB Output is correct
209 Correct 496 ms 1752 KB Output is correct
210 Correct 363 ms 2144 KB Output is correct
211 Correct 376 ms 1700 KB Output is correct
212 Correct 400 ms 1684 KB Output is correct
213 Correct 367 ms 1540 KB Output is correct
214 Correct 356 ms 1980 KB Output is correct
215 Correct 367 ms 1664 KB Output is correct
216 Correct 392 ms 1772 KB Output is correct
217 Correct 356 ms 1696 KB Output is correct
218 Correct 351 ms 1428 KB Output is correct
219 Correct 379 ms 1816 KB Output is correct
220 Correct 404 ms 2000 KB Output is correct
221 Correct 381 ms 1996 KB Output is correct
222 Correct 358 ms 1480 KB Output is correct
223 Correct 371 ms 1632 KB Output is correct
224 Correct 399 ms 1880 KB Output is correct
225 Correct 426 ms 1444 KB Output is correct
226 Correct 378 ms 2180 KB Output is correct