Submission #709866

# Submission time Handle Problem Language Result Execution time Memory
709866 2023-03-14T18:06:04 Z doowey Mars (APIO22_mars) C++17
54 / 100
482 ms 3844 KB
#include "mars.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair

pair<pii, pii> rect(int i, int j, int k, int n){
    int side = 2 * n + 1 - k * 2;
    int len = (2 * n + 1) / side;
    int rem = (2 * n + 1) % side;
    int i0 = i * len;
    int i1 = len;
    if(i >= side - rem){
        i0 += i - (side - rem);
        i1 = len + 1;
    }
    i1 += i0 - 1;
    int j0 = j * len;
    int j1 = len;
    if(j >= side - rem){
        j0 += j - (side - rem);
        j1 = len + 1;
    }
    j1 += j0 - 1;
    return mp(mp(i0, j0), mp(i1, j1));
    //
    // len, len, len, len ... len
}

string process(vector <vector<string>> a, int i, int j, int k, int n)
{
    pair<pii, pii> need = rect(i, j, k + 1, n);
    pair<pii, pii> has;
    int nn = need.se.fi - need.fi.fi + 1;
    int mm = need.se.se - need.fi.se + 1;
    vector<vector<char>> C(nn);
    for(int i = 0 ; i < nn; i ++ ){
        C[i].resize(mm, '0');
    }
    int idx;
    for(int di = 0 ; di < 3; di ++ ){
        for(int dj = 0 ; dj < 3; dj ++ ){
            has = rect(i + di, j + dj, k, n);
            idx = 0;
            for(int p = has.fi.fi; p <= has.se.fi; p ++ ){
                for(int q = has.fi.se; q <= has.se.se; q ++ ){
                    if(need.fi.fi <= p && p <= need.se.fi && need.fi.se <= q && q <= need.se.se){
                        C[p - need.fi.fi][q - need.fi.se] = a[di][dj][idx];
                    }
                    idx ++ ;
                }
            }
        }
    }
    /*
    if(k == 0){
        cout << i << " " << j << "\n";
        for(auto x : C){
            for(auto y : x) cout << y;
            cout << "\n";
        }
        cout << "---------\n";
    }
    */
    if(k < n - 1){
        string ret;
        for(auto ii : C){
            for(auto jj : ii){
                ret.push_back(jj);
            }
        }
        while(ret.size() < 100) ret.push_back('0');
        return ret;
    }
    int cummies = 0;
    queue<pii> G;
    pii nd;
    pii nx;
    int res = 0;
    for(int i = 0 ; i < nn; i ++ ){
        for(int j = 0 ; j < mm ; j ++ ){
            if(C[i][j] == '1'){
                G.push(mp(i,j));
                C[i][j]='0';
                res ++ ;
                while(!G.empty()){
                    nd = G.front();
                    G.pop();
                    for(int di = -1; di <= +1; di ++ ){
                        for(int dj = -1; dj <= + 1; dj ++ ){
                            if(abs(di) + abs(dj) == 1){
                                nx = mp(nd.fi + di, nd.se + dj);
                                if(nx.fi >= 0 && nx.se >= 0 && nx.fi < nn && nx.se < mm){
                                    if(C[nx.fi][nx.se] == '1'){
                                        C[nx.fi][nx.se] = '0';
                                        G.push(nx);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    string soln;
    for(int i = 0 ; i < 25; i ++ ){
        if((res & (1 << i))) soln.push_back('1');
        else soln.push_back('0');
    }
    while(soln.size() < 100) soln.push_back('0');
    return soln;
}

Compilation message

mars.cpp: In function 'std::string process(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:81:9: warning: unused variable 'cummies' [-Wunused-variable]
   81 |     int cummies = 0;
      |         ^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2148 KB Output is correct
2 Correct 7 ms 1880 KB Output is correct
3 Correct 8 ms 2136 KB Output is correct
4 Correct 8 ms 2144 KB Output is correct
5 Correct 8 ms 2000 KB Output is correct
6 Correct 8 ms 2000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2148 KB Output is correct
2 Correct 7 ms 1880 KB Output is correct
3 Correct 8 ms 2136 KB Output is correct
4 Correct 8 ms 2144 KB Output is correct
5 Correct 8 ms 2000 KB Output is correct
6 Correct 8 ms 2000 KB Output is correct
7 Correct 11 ms 1908 KB Output is correct
8 Correct 16 ms 2020 KB Output is correct
9 Correct 16 ms 1808 KB Output is correct
10 Correct 16 ms 1960 KB Output is correct
11 Correct 17 ms 2172 KB Output is correct
12 Correct 16 ms 1948 KB Output is correct
13 Correct 16 ms 2060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2148 KB Output is correct
2 Correct 7 ms 1880 KB Output is correct
3 Correct 8 ms 2136 KB Output is correct
4 Correct 8 ms 2144 KB Output is correct
5 Correct 8 ms 2000 KB Output is correct
6 Correct 8 ms 2000 KB Output is correct
7 Correct 11 ms 1908 KB Output is correct
8 Correct 16 ms 2020 KB Output is correct
9 Correct 16 ms 1808 KB Output is correct
10 Correct 16 ms 1960 KB Output is correct
11 Correct 17 ms 2172 KB Output is correct
12 Correct 16 ms 1948 KB Output is correct
13 Correct 16 ms 2060 KB Output is correct
14 Correct 32 ms 2552 KB Output is correct
15 Correct 43 ms 2600 KB Output is correct
16 Correct 44 ms 2536 KB Output is correct
17 Correct 44 ms 2516 KB Output is correct
18 Correct 42 ms 2584 KB Output is correct
19 Correct 48 ms 2508 KB Output is correct
20 Correct 40 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2148 KB Output is correct
2 Correct 7 ms 1880 KB Output is correct
3 Correct 8 ms 2136 KB Output is correct
4 Correct 8 ms 2144 KB Output is correct
5 Correct 8 ms 2000 KB Output is correct
6 Correct 8 ms 2000 KB Output is correct
7 Correct 11 ms 1908 KB Output is correct
8 Correct 16 ms 2020 KB Output is correct
9 Correct 16 ms 1808 KB Output is correct
10 Correct 16 ms 1960 KB Output is correct
11 Correct 17 ms 2172 KB Output is correct
12 Correct 16 ms 1948 KB Output is correct
13 Correct 16 ms 2060 KB Output is correct
14 Correct 32 ms 2552 KB Output is correct
15 Correct 43 ms 2600 KB Output is correct
16 Correct 44 ms 2536 KB Output is correct
17 Correct 44 ms 2516 KB Output is correct
18 Correct 42 ms 2584 KB Output is correct
19 Correct 48 ms 2508 KB Output is correct
20 Correct 40 ms 2552 KB Output is correct
21 Correct 68 ms 2608 KB Output is correct
22 Correct 94 ms 2708 KB Output is correct
23 Correct 99 ms 2640 KB Output is correct
24 Correct 94 ms 2760 KB Output is correct
25 Correct 97 ms 2716 KB Output is correct
26 Correct 91 ms 2796 KB Output is correct
27 Correct 93 ms 2712 KB Output is correct
28 Correct 93 ms 2708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2148 KB Output is correct
2 Correct 7 ms 1880 KB Output is correct
3 Correct 8 ms 2136 KB Output is correct
4 Correct 8 ms 2144 KB Output is correct
5 Correct 8 ms 2000 KB Output is correct
6 Correct 8 ms 2000 KB Output is correct
7 Correct 11 ms 1908 KB Output is correct
8 Correct 16 ms 2020 KB Output is correct
9 Correct 16 ms 1808 KB Output is correct
10 Correct 16 ms 1960 KB Output is correct
11 Correct 17 ms 2172 KB Output is correct
12 Correct 16 ms 1948 KB Output is correct
13 Correct 16 ms 2060 KB Output is correct
14 Correct 32 ms 2552 KB Output is correct
15 Correct 43 ms 2600 KB Output is correct
16 Correct 44 ms 2536 KB Output is correct
17 Correct 44 ms 2516 KB Output is correct
18 Correct 42 ms 2584 KB Output is correct
19 Correct 48 ms 2508 KB Output is correct
20 Correct 40 ms 2552 KB Output is correct
21 Correct 68 ms 2608 KB Output is correct
22 Correct 94 ms 2708 KB Output is correct
23 Correct 99 ms 2640 KB Output is correct
24 Correct 94 ms 2760 KB Output is correct
25 Correct 97 ms 2716 KB Output is correct
26 Correct 91 ms 2796 KB Output is correct
27 Correct 93 ms 2712 KB Output is correct
28 Correct 93 ms 2708 KB Output is correct
29 Correct 126 ms 2796 KB Output is correct
30 Correct 175 ms 3076 KB Output is correct
31 Correct 180 ms 2940 KB Output is correct
32 Correct 183 ms 3036 KB Output is correct
33 Correct 176 ms 2968 KB Output is correct
34 Correct 179 ms 3124 KB Output is correct
35 Correct 176 ms 3068 KB Output is correct
36 Correct 174 ms 3036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2148 KB Output is correct
2 Correct 7 ms 1880 KB Output is correct
3 Correct 8 ms 2136 KB Output is correct
4 Correct 8 ms 2144 KB Output is correct
5 Correct 8 ms 2000 KB Output is correct
6 Correct 8 ms 2000 KB Output is correct
7 Correct 11 ms 1908 KB Output is correct
8 Correct 16 ms 2020 KB Output is correct
9 Correct 16 ms 1808 KB Output is correct
10 Correct 16 ms 1960 KB Output is correct
11 Correct 17 ms 2172 KB Output is correct
12 Correct 16 ms 1948 KB Output is correct
13 Correct 16 ms 2060 KB Output is correct
14 Correct 32 ms 2552 KB Output is correct
15 Correct 43 ms 2600 KB Output is correct
16 Correct 44 ms 2536 KB Output is correct
17 Correct 44 ms 2516 KB Output is correct
18 Correct 42 ms 2584 KB Output is correct
19 Correct 48 ms 2508 KB Output is correct
20 Correct 40 ms 2552 KB Output is correct
21 Correct 68 ms 2608 KB Output is correct
22 Correct 94 ms 2708 KB Output is correct
23 Correct 99 ms 2640 KB Output is correct
24 Correct 94 ms 2760 KB Output is correct
25 Correct 97 ms 2716 KB Output is correct
26 Correct 91 ms 2796 KB Output is correct
27 Correct 93 ms 2712 KB Output is correct
28 Correct 93 ms 2708 KB Output is correct
29 Correct 126 ms 2796 KB Output is correct
30 Correct 175 ms 3076 KB Output is correct
31 Correct 180 ms 2940 KB Output is correct
32 Correct 183 ms 3036 KB Output is correct
33 Correct 176 ms 2968 KB Output is correct
34 Correct 179 ms 3124 KB Output is correct
35 Correct 176 ms 3068 KB Output is correct
36 Correct 174 ms 3036 KB Output is correct
37 Correct 236 ms 3280 KB Output is correct
38 Correct 297 ms 3296 KB Output is correct
39 Correct 299 ms 3236 KB Output is correct
40 Correct 311 ms 3276 KB Output is correct
41 Correct 291 ms 3272 KB Output is correct
42 Correct 287 ms 3244 KB Output is correct
43 Correct 309 ms 3424 KB Output is correct
44 Correct 295 ms 3404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2148 KB Output is correct
2 Correct 7 ms 1880 KB Output is correct
3 Correct 8 ms 2136 KB Output is correct
4 Correct 8 ms 2144 KB Output is correct
5 Correct 8 ms 2000 KB Output is correct
6 Correct 8 ms 2000 KB Output is correct
7 Correct 11 ms 1908 KB Output is correct
8 Correct 16 ms 2020 KB Output is correct
9 Correct 16 ms 1808 KB Output is correct
10 Correct 16 ms 1960 KB Output is correct
11 Correct 17 ms 2172 KB Output is correct
12 Correct 16 ms 1948 KB Output is correct
13 Correct 16 ms 2060 KB Output is correct
14 Correct 32 ms 2552 KB Output is correct
15 Correct 43 ms 2600 KB Output is correct
16 Correct 44 ms 2536 KB Output is correct
17 Correct 44 ms 2516 KB Output is correct
18 Correct 42 ms 2584 KB Output is correct
19 Correct 48 ms 2508 KB Output is correct
20 Correct 40 ms 2552 KB Output is correct
21 Correct 68 ms 2608 KB Output is correct
22 Correct 94 ms 2708 KB Output is correct
23 Correct 99 ms 2640 KB Output is correct
24 Correct 94 ms 2760 KB Output is correct
25 Correct 97 ms 2716 KB Output is correct
26 Correct 91 ms 2796 KB Output is correct
27 Correct 93 ms 2712 KB Output is correct
28 Correct 93 ms 2708 KB Output is correct
29 Correct 126 ms 2796 KB Output is correct
30 Correct 175 ms 3076 KB Output is correct
31 Correct 180 ms 2940 KB Output is correct
32 Correct 183 ms 3036 KB Output is correct
33 Correct 176 ms 2968 KB Output is correct
34 Correct 179 ms 3124 KB Output is correct
35 Correct 176 ms 3068 KB Output is correct
36 Correct 174 ms 3036 KB Output is correct
37 Correct 236 ms 3280 KB Output is correct
38 Correct 297 ms 3296 KB Output is correct
39 Correct 299 ms 3236 KB Output is correct
40 Correct 311 ms 3276 KB Output is correct
41 Correct 291 ms 3272 KB Output is correct
42 Correct 287 ms 3244 KB Output is correct
43 Correct 309 ms 3424 KB Output is correct
44 Correct 295 ms 3404 KB Output is correct
45 Correct 382 ms 3572 KB Output is correct
46 Correct 478 ms 3792 KB Output is correct
47 Correct 452 ms 3664 KB Output is correct
48 Correct 482 ms 3652 KB Output is correct
49 Correct 468 ms 3844 KB Output is correct
50 Correct 450 ms 3612 KB Output is correct
51 Correct 469 ms 3668 KB Output is correct
52 Correct 464 ms 3648 KB Output is correct
53 Correct 476 ms 3692 KB Output is correct
54 Correct 477 ms 3648 KB Output is correct
55 Correct 470 ms 3688 KB Output is correct
56 Correct 477 ms 3692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2148 KB Output is correct
2 Correct 7 ms 1880 KB Output is correct
3 Correct 8 ms 2136 KB Output is correct
4 Correct 8 ms 2144 KB Output is correct
5 Correct 8 ms 2000 KB Output is correct
6 Correct 8 ms 2000 KB Output is correct
7 Correct 11 ms 1908 KB Output is correct
8 Correct 16 ms 2020 KB Output is correct
9 Correct 16 ms 1808 KB Output is correct
10 Correct 16 ms 1960 KB Output is correct
11 Correct 17 ms 2172 KB Output is correct
12 Correct 16 ms 1948 KB Output is correct
13 Correct 16 ms 2060 KB Output is correct
14 Correct 32 ms 2552 KB Output is correct
15 Correct 43 ms 2600 KB Output is correct
16 Correct 44 ms 2536 KB Output is correct
17 Correct 44 ms 2516 KB Output is correct
18 Correct 42 ms 2584 KB Output is correct
19 Correct 48 ms 2508 KB Output is correct
20 Correct 40 ms 2552 KB Output is correct
21 Correct 68 ms 2608 KB Output is correct
22 Correct 94 ms 2708 KB Output is correct
23 Correct 99 ms 2640 KB Output is correct
24 Correct 94 ms 2760 KB Output is correct
25 Correct 97 ms 2716 KB Output is correct
26 Correct 91 ms 2796 KB Output is correct
27 Correct 93 ms 2712 KB Output is correct
28 Correct 93 ms 2708 KB Output is correct
29 Correct 126 ms 2796 KB Output is correct
30 Correct 175 ms 3076 KB Output is correct
31 Correct 180 ms 2940 KB Output is correct
32 Correct 183 ms 3036 KB Output is correct
33 Correct 176 ms 2968 KB Output is correct
34 Correct 179 ms 3124 KB Output is correct
35 Correct 176 ms 3068 KB Output is correct
36 Correct 174 ms 3036 KB Output is correct
37 Correct 236 ms 3280 KB Output is correct
38 Correct 297 ms 3296 KB Output is correct
39 Correct 299 ms 3236 KB Output is correct
40 Correct 311 ms 3276 KB Output is correct
41 Correct 291 ms 3272 KB Output is correct
42 Correct 287 ms 3244 KB Output is correct
43 Correct 309 ms 3424 KB Output is correct
44 Correct 295 ms 3404 KB Output is correct
45 Correct 382 ms 3572 KB Output is correct
46 Correct 478 ms 3792 KB Output is correct
47 Correct 452 ms 3664 KB Output is correct
48 Correct 482 ms 3652 KB Output is correct
49 Correct 468 ms 3844 KB Output is correct
50 Correct 450 ms 3612 KB Output is correct
51 Correct 469 ms 3668 KB Output is correct
52 Correct 464 ms 3648 KB Output is correct
53 Correct 476 ms 3692 KB Output is correct
54 Correct 477 ms 3648 KB Output is correct
55 Correct 470 ms 3688 KB Output is correct
56 Correct 477 ms 3692 KB Output is correct
57 Incorrect 73 ms 488 KB invalid len
58 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2148 KB Output is correct
2 Correct 7 ms 1880 KB Output is correct
3 Correct 8 ms 2136 KB Output is correct
4 Correct 8 ms 2144 KB Output is correct
5 Correct 8 ms 2000 KB Output is correct
6 Correct 8 ms 2000 KB Output is correct
7 Correct 11 ms 1908 KB Output is correct
8 Correct 16 ms 2020 KB Output is correct
9 Correct 16 ms 1808 KB Output is correct
10 Correct 16 ms 1960 KB Output is correct
11 Correct 17 ms 2172 KB Output is correct
12 Correct 16 ms 1948 KB Output is correct
13 Correct 16 ms 2060 KB Output is correct
14 Correct 32 ms 2552 KB Output is correct
15 Correct 43 ms 2600 KB Output is correct
16 Correct 44 ms 2536 KB Output is correct
17 Correct 44 ms 2516 KB Output is correct
18 Correct 42 ms 2584 KB Output is correct
19 Correct 48 ms 2508 KB Output is correct
20 Correct 40 ms 2552 KB Output is correct
21 Correct 68 ms 2608 KB Output is correct
22 Correct 94 ms 2708 KB Output is correct
23 Correct 99 ms 2640 KB Output is correct
24 Correct 94 ms 2760 KB Output is correct
25 Correct 97 ms 2716 KB Output is correct
26 Correct 91 ms 2796 KB Output is correct
27 Correct 93 ms 2712 KB Output is correct
28 Correct 93 ms 2708 KB Output is correct
29 Correct 126 ms 2796 KB Output is correct
30 Correct 175 ms 3076 KB Output is correct
31 Correct 180 ms 2940 KB Output is correct
32 Correct 183 ms 3036 KB Output is correct
33 Correct 176 ms 2968 KB Output is correct
34 Correct 179 ms 3124 KB Output is correct
35 Correct 176 ms 3068 KB Output is correct
36 Correct 174 ms 3036 KB Output is correct
37 Correct 236 ms 3280 KB Output is correct
38 Correct 297 ms 3296 KB Output is correct
39 Correct 299 ms 3236 KB Output is correct
40 Correct 311 ms 3276 KB Output is correct
41 Correct 291 ms 3272 KB Output is correct
42 Correct 287 ms 3244 KB Output is correct
43 Correct 309 ms 3424 KB Output is correct
44 Correct 295 ms 3404 KB Output is correct
45 Correct 382 ms 3572 KB Output is correct
46 Correct 478 ms 3792 KB Output is correct
47 Correct 452 ms 3664 KB Output is correct
48 Correct 482 ms 3652 KB Output is correct
49 Correct 468 ms 3844 KB Output is correct
50 Correct 450 ms 3612 KB Output is correct
51 Correct 469 ms 3668 KB Output is correct
52 Correct 464 ms 3648 KB Output is correct
53 Correct 476 ms 3692 KB Output is correct
54 Correct 477 ms 3648 KB Output is correct
55 Correct 470 ms 3688 KB Output is correct
56 Correct 477 ms 3692 KB Output is correct
57 Incorrect 73 ms 488 KB invalid len
58 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2148 KB Output is correct
2 Correct 7 ms 1880 KB Output is correct
3 Correct 8 ms 2136 KB Output is correct
4 Correct 8 ms 2144 KB Output is correct
5 Correct 8 ms 2000 KB Output is correct
6 Correct 8 ms 2000 KB Output is correct
7 Correct 11 ms 1908 KB Output is correct
8 Correct 16 ms 2020 KB Output is correct
9 Correct 16 ms 1808 KB Output is correct
10 Correct 16 ms 1960 KB Output is correct
11 Correct 17 ms 2172 KB Output is correct
12 Correct 16 ms 1948 KB Output is correct
13 Correct 16 ms 2060 KB Output is correct
14 Correct 32 ms 2552 KB Output is correct
15 Correct 43 ms 2600 KB Output is correct
16 Correct 44 ms 2536 KB Output is correct
17 Correct 44 ms 2516 KB Output is correct
18 Correct 42 ms 2584 KB Output is correct
19 Correct 48 ms 2508 KB Output is correct
20 Correct 40 ms 2552 KB Output is correct
21 Correct 68 ms 2608 KB Output is correct
22 Correct 94 ms 2708 KB Output is correct
23 Correct 99 ms 2640 KB Output is correct
24 Correct 94 ms 2760 KB Output is correct
25 Correct 97 ms 2716 KB Output is correct
26 Correct 91 ms 2796 KB Output is correct
27 Correct 93 ms 2712 KB Output is correct
28 Correct 93 ms 2708 KB Output is correct
29 Correct 126 ms 2796 KB Output is correct
30 Correct 175 ms 3076 KB Output is correct
31 Correct 180 ms 2940 KB Output is correct
32 Correct 183 ms 3036 KB Output is correct
33 Correct 176 ms 2968 KB Output is correct
34 Correct 179 ms 3124 KB Output is correct
35 Correct 176 ms 3068 KB Output is correct
36 Correct 174 ms 3036 KB Output is correct
37 Correct 236 ms 3280 KB Output is correct
38 Correct 297 ms 3296 KB Output is correct
39 Correct 299 ms 3236 KB Output is correct
40 Correct 311 ms 3276 KB Output is correct
41 Correct 291 ms 3272 KB Output is correct
42 Correct 287 ms 3244 KB Output is correct
43 Correct 309 ms 3424 KB Output is correct
44 Correct 295 ms 3404 KB Output is correct
45 Correct 382 ms 3572 KB Output is correct
46 Correct 478 ms 3792 KB Output is correct
47 Correct 452 ms 3664 KB Output is correct
48 Correct 482 ms 3652 KB Output is correct
49 Correct 468 ms 3844 KB Output is correct
50 Correct 450 ms 3612 KB Output is correct
51 Correct 469 ms 3668 KB Output is correct
52 Correct 464 ms 3648 KB Output is correct
53 Correct 476 ms 3692 KB Output is correct
54 Correct 477 ms 3648 KB Output is correct
55 Correct 470 ms 3688 KB Output is correct
56 Correct 477 ms 3692 KB Output is correct
57 Incorrect 73 ms 488 KB invalid len
58 Halted 0 ms 0 KB -