Submission #960288

# Submission time Handle Problem Language Result Execution time Memory
960288 2024-04-10T07:33:25 Z Wansur Mars (APIO22_mars) C++17
54 / 100
285 ms 5448 KB
#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n'
//#define int long long

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")

const int dx[]={-1, 1, 0, 0, 0};
const int dy[]={0, 0, 1, -1, 0};
typedef long long ll;
using namespace std;
const int mx=50+12;
const int mod=998244353;
const bool T=1;

bool used[mx][mx];
int c[mx][mx];

void dfs(int x,int y,int n){
    used[x][y]=1;
    for(int i=0;i<4;i++){
        int x1=dx[i]+x;
        int y1=dy[i]+y;
        if(x1>=0 && y1>=0 && x1<n && y1<n && !used[x1][y1]){
            dfs(x1, y1, n);
        }
    }
}

string gn(int n) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            used[i][j] ^= 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (!used[i][j]){
                dfs(i, j, n);
                cnt++;
            }
        }
    }
    string ans="";
    for(int i=0;i<20;i++){
        if((cnt&(1<<i))){
            ans+='1';
        }
        else{
            ans+='0';
        }
    }
    while(ans.size()<100){
        ans+='0';
    }
    return ans;
}

pair<int,int> opt(int l,int r,int k, int n){
    int tl = l * (2 * n + 1) / (2 * (n - k) + 1);
    int tr = (l+1) * (2 * n + 1) / (2 * (n - k) + 1)-1;
    return {tl, tr};
}

void upd(string s,int i,int j,int k, int n){
    auto [tli, tri] = opt(i, i+2*k, k, n);
    auto [tlj, trj] = opt(j, j+2*k, k, n);
    int pos=0;
    for(int i=tli;i<=tri;i++){
        for(int j=tlj;j<=trj;j++){
            used[i][j] = (s[pos] == '1');
            pos++;
        }
    }
}

string process(vector<vector<string> > a,int x,int y,int k,int n){
    k++;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            upd(a[i][j], x+i, y+j, k-1, n);
        }
    }
    auto [tli, tri] = opt(x, x+2*k, min(n-1, k), n);
    auto [tlj, trj] = opt(y, y+2*k, min(n-1, k), n);
    string ans="";
    for(int i=tli;i<=tri;i++){
        for(int j=tlj;j<=trj;j++){
            ans += char(used[i][j] + '0');
        }
    }
    while(ans.size() < 100){
        ans+='0';
    }
    if(n==k){
        return gn(n * 2 + 1);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4024 KB Output is correct
2 Correct 5 ms 4408 KB Output is correct
3 Correct 6 ms 3692 KB Output is correct
4 Correct 7 ms 3648 KB Output is correct
5 Correct 7 ms 3964 KB Output is correct
6 Correct 5 ms 3856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4024 KB Output is correct
2 Correct 5 ms 4408 KB Output is correct
3 Correct 6 ms 3692 KB Output is correct
4 Correct 7 ms 3648 KB Output is correct
5 Correct 7 ms 3964 KB Output is correct
6 Correct 5 ms 3856 KB Output is correct
7 Correct 8 ms 3644 KB Output is correct
8 Correct 8 ms 3632 KB Output is correct
9 Correct 9 ms 4076 KB Output is correct
10 Correct 10 ms 3960 KB Output is correct
11 Correct 9 ms 4088 KB Output is correct
12 Correct 8 ms 4168 KB Output is correct
13 Correct 9 ms 3792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4024 KB Output is correct
2 Correct 5 ms 4408 KB Output is correct
3 Correct 6 ms 3692 KB Output is correct
4 Correct 7 ms 3648 KB Output is correct
5 Correct 7 ms 3964 KB Output is correct
6 Correct 5 ms 3856 KB Output is correct
7 Correct 8 ms 3644 KB Output is correct
8 Correct 8 ms 3632 KB Output is correct
9 Correct 9 ms 4076 KB Output is correct
10 Correct 10 ms 3960 KB Output is correct
11 Correct 9 ms 4088 KB Output is correct
12 Correct 8 ms 4168 KB Output is correct
13 Correct 9 ms 3792 KB Output is correct
14 Correct 17 ms 3920 KB Output is correct
15 Correct 23 ms 3960 KB Output is correct
16 Correct 24 ms 4176 KB Output is correct
17 Correct 24 ms 4652 KB Output is correct
18 Correct 24 ms 4136 KB Output is correct
19 Correct 24 ms 4728 KB Output is correct
20 Correct 23 ms 3896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4024 KB Output is correct
2 Correct 5 ms 4408 KB Output is correct
3 Correct 6 ms 3692 KB Output is correct
4 Correct 7 ms 3648 KB Output is correct
5 Correct 7 ms 3964 KB Output is correct
6 Correct 5 ms 3856 KB Output is correct
7 Correct 8 ms 3644 KB Output is correct
8 Correct 8 ms 3632 KB Output is correct
9 Correct 9 ms 4076 KB Output is correct
10 Correct 10 ms 3960 KB Output is correct
11 Correct 9 ms 4088 KB Output is correct
12 Correct 8 ms 4168 KB Output is correct
13 Correct 9 ms 3792 KB Output is correct
14 Correct 17 ms 3920 KB Output is correct
15 Correct 23 ms 3960 KB Output is correct
16 Correct 24 ms 4176 KB Output is correct
17 Correct 24 ms 4652 KB Output is correct
18 Correct 24 ms 4136 KB Output is correct
19 Correct 24 ms 4728 KB Output is correct
20 Correct 23 ms 3896 KB Output is correct
21 Correct 38 ms 4148 KB Output is correct
22 Correct 55 ms 4364 KB Output is correct
23 Correct 52 ms 3820 KB Output is correct
24 Correct 53 ms 4376 KB Output is correct
25 Correct 55 ms 4136 KB Output is correct
26 Correct 55 ms 4488 KB Output is correct
27 Correct 51 ms 4512 KB Output is correct
28 Correct 54 ms 4000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4024 KB Output is correct
2 Correct 5 ms 4408 KB Output is correct
3 Correct 6 ms 3692 KB Output is correct
4 Correct 7 ms 3648 KB Output is correct
5 Correct 7 ms 3964 KB Output is correct
6 Correct 5 ms 3856 KB Output is correct
7 Correct 8 ms 3644 KB Output is correct
8 Correct 8 ms 3632 KB Output is correct
9 Correct 9 ms 4076 KB Output is correct
10 Correct 10 ms 3960 KB Output is correct
11 Correct 9 ms 4088 KB Output is correct
12 Correct 8 ms 4168 KB Output is correct
13 Correct 9 ms 3792 KB Output is correct
14 Correct 17 ms 3920 KB Output is correct
15 Correct 23 ms 3960 KB Output is correct
16 Correct 24 ms 4176 KB Output is correct
17 Correct 24 ms 4652 KB Output is correct
18 Correct 24 ms 4136 KB Output is correct
19 Correct 24 ms 4728 KB Output is correct
20 Correct 23 ms 3896 KB Output is correct
21 Correct 38 ms 4148 KB Output is correct
22 Correct 55 ms 4364 KB Output is correct
23 Correct 52 ms 3820 KB Output is correct
24 Correct 53 ms 4376 KB Output is correct
25 Correct 55 ms 4136 KB Output is correct
26 Correct 55 ms 4488 KB Output is correct
27 Correct 51 ms 4512 KB Output is correct
28 Correct 54 ms 4000 KB Output is correct
29 Correct 75 ms 4696 KB Output is correct
30 Correct 104 ms 4200 KB Output is correct
31 Correct 100 ms 4020 KB Output is correct
32 Correct 102 ms 4568 KB Output is correct
33 Correct 106 ms 4620 KB Output is correct
34 Correct 97 ms 4480 KB Output is correct
35 Correct 108 ms 4216 KB Output is correct
36 Correct 99 ms 4016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4024 KB Output is correct
2 Correct 5 ms 4408 KB Output is correct
3 Correct 6 ms 3692 KB Output is correct
4 Correct 7 ms 3648 KB Output is correct
5 Correct 7 ms 3964 KB Output is correct
6 Correct 5 ms 3856 KB Output is correct
7 Correct 8 ms 3644 KB Output is correct
8 Correct 8 ms 3632 KB Output is correct
9 Correct 9 ms 4076 KB Output is correct
10 Correct 10 ms 3960 KB Output is correct
11 Correct 9 ms 4088 KB Output is correct
12 Correct 8 ms 4168 KB Output is correct
13 Correct 9 ms 3792 KB Output is correct
14 Correct 17 ms 3920 KB Output is correct
15 Correct 23 ms 3960 KB Output is correct
16 Correct 24 ms 4176 KB Output is correct
17 Correct 24 ms 4652 KB Output is correct
18 Correct 24 ms 4136 KB Output is correct
19 Correct 24 ms 4728 KB Output is correct
20 Correct 23 ms 3896 KB Output is correct
21 Correct 38 ms 4148 KB Output is correct
22 Correct 55 ms 4364 KB Output is correct
23 Correct 52 ms 3820 KB Output is correct
24 Correct 53 ms 4376 KB Output is correct
25 Correct 55 ms 4136 KB Output is correct
26 Correct 55 ms 4488 KB Output is correct
27 Correct 51 ms 4512 KB Output is correct
28 Correct 54 ms 4000 KB Output is correct
29 Correct 75 ms 4696 KB Output is correct
30 Correct 104 ms 4200 KB Output is correct
31 Correct 100 ms 4020 KB Output is correct
32 Correct 102 ms 4568 KB Output is correct
33 Correct 106 ms 4620 KB Output is correct
34 Correct 97 ms 4480 KB Output is correct
35 Correct 108 ms 4216 KB Output is correct
36 Correct 99 ms 4016 KB Output is correct
37 Correct 137 ms 4212 KB Output is correct
38 Correct 178 ms 5032 KB Output is correct
39 Correct 175 ms 4688 KB Output is correct
40 Correct 178 ms 4924 KB Output is correct
41 Correct 166 ms 4600 KB Output is correct
42 Correct 166 ms 4580 KB Output is correct
43 Correct 166 ms 5000 KB Output is correct
44 Correct 173 ms 4592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4024 KB Output is correct
2 Correct 5 ms 4408 KB Output is correct
3 Correct 6 ms 3692 KB Output is correct
4 Correct 7 ms 3648 KB Output is correct
5 Correct 7 ms 3964 KB Output is correct
6 Correct 5 ms 3856 KB Output is correct
7 Correct 8 ms 3644 KB Output is correct
8 Correct 8 ms 3632 KB Output is correct
9 Correct 9 ms 4076 KB Output is correct
10 Correct 10 ms 3960 KB Output is correct
11 Correct 9 ms 4088 KB Output is correct
12 Correct 8 ms 4168 KB Output is correct
13 Correct 9 ms 3792 KB Output is correct
14 Correct 17 ms 3920 KB Output is correct
15 Correct 23 ms 3960 KB Output is correct
16 Correct 24 ms 4176 KB Output is correct
17 Correct 24 ms 4652 KB Output is correct
18 Correct 24 ms 4136 KB Output is correct
19 Correct 24 ms 4728 KB Output is correct
20 Correct 23 ms 3896 KB Output is correct
21 Correct 38 ms 4148 KB Output is correct
22 Correct 55 ms 4364 KB Output is correct
23 Correct 52 ms 3820 KB Output is correct
24 Correct 53 ms 4376 KB Output is correct
25 Correct 55 ms 4136 KB Output is correct
26 Correct 55 ms 4488 KB Output is correct
27 Correct 51 ms 4512 KB Output is correct
28 Correct 54 ms 4000 KB Output is correct
29 Correct 75 ms 4696 KB Output is correct
30 Correct 104 ms 4200 KB Output is correct
31 Correct 100 ms 4020 KB Output is correct
32 Correct 102 ms 4568 KB Output is correct
33 Correct 106 ms 4620 KB Output is correct
34 Correct 97 ms 4480 KB Output is correct
35 Correct 108 ms 4216 KB Output is correct
36 Correct 99 ms 4016 KB Output is correct
37 Correct 137 ms 4212 KB Output is correct
38 Correct 178 ms 5032 KB Output is correct
39 Correct 175 ms 4688 KB Output is correct
40 Correct 178 ms 4924 KB Output is correct
41 Correct 166 ms 4600 KB Output is correct
42 Correct 166 ms 4580 KB Output is correct
43 Correct 166 ms 5000 KB Output is correct
44 Correct 173 ms 4592 KB Output is correct
45 Correct 221 ms 5208 KB Output is correct
46 Correct 269 ms 5068 KB Output is correct
47 Correct 275 ms 5448 KB Output is correct
48 Correct 274 ms 4860 KB Output is correct
49 Correct 267 ms 5012 KB Output is correct
50 Correct 285 ms 5128 KB Output is correct
51 Correct 268 ms 5216 KB Output is correct
52 Correct 281 ms 4908 KB Output is correct
53 Correct 259 ms 4876 KB Output is correct
54 Correct 274 ms 4860 KB Output is correct
55 Correct 264 ms 4832 KB Output is correct
56 Correct 265 ms 5148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4024 KB Output is correct
2 Correct 5 ms 4408 KB Output is correct
3 Correct 6 ms 3692 KB Output is correct
4 Correct 7 ms 3648 KB Output is correct
5 Correct 7 ms 3964 KB Output is correct
6 Correct 5 ms 3856 KB Output is correct
7 Correct 8 ms 3644 KB Output is correct
8 Correct 8 ms 3632 KB Output is correct
9 Correct 9 ms 4076 KB Output is correct
10 Correct 10 ms 3960 KB Output is correct
11 Correct 9 ms 4088 KB Output is correct
12 Correct 8 ms 4168 KB Output is correct
13 Correct 9 ms 3792 KB Output is correct
14 Correct 17 ms 3920 KB Output is correct
15 Correct 23 ms 3960 KB Output is correct
16 Correct 24 ms 4176 KB Output is correct
17 Correct 24 ms 4652 KB Output is correct
18 Correct 24 ms 4136 KB Output is correct
19 Correct 24 ms 4728 KB Output is correct
20 Correct 23 ms 3896 KB Output is correct
21 Correct 38 ms 4148 KB Output is correct
22 Correct 55 ms 4364 KB Output is correct
23 Correct 52 ms 3820 KB Output is correct
24 Correct 53 ms 4376 KB Output is correct
25 Correct 55 ms 4136 KB Output is correct
26 Correct 55 ms 4488 KB Output is correct
27 Correct 51 ms 4512 KB Output is correct
28 Correct 54 ms 4000 KB Output is correct
29 Correct 75 ms 4696 KB Output is correct
30 Correct 104 ms 4200 KB Output is correct
31 Correct 100 ms 4020 KB Output is correct
32 Correct 102 ms 4568 KB Output is correct
33 Correct 106 ms 4620 KB Output is correct
34 Correct 97 ms 4480 KB Output is correct
35 Correct 108 ms 4216 KB Output is correct
36 Correct 99 ms 4016 KB Output is correct
37 Correct 137 ms 4212 KB Output is correct
38 Correct 178 ms 5032 KB Output is correct
39 Correct 175 ms 4688 KB Output is correct
40 Correct 178 ms 4924 KB Output is correct
41 Correct 166 ms 4600 KB Output is correct
42 Correct 166 ms 4580 KB Output is correct
43 Correct 166 ms 5000 KB Output is correct
44 Correct 173 ms 4592 KB Output is correct
45 Correct 221 ms 5208 KB Output is correct
46 Correct 269 ms 5068 KB Output is correct
47 Correct 275 ms 5448 KB Output is correct
48 Correct 274 ms 4860 KB Output is correct
49 Correct 267 ms 5012 KB Output is correct
50 Correct 285 ms 5128 KB Output is correct
51 Correct 268 ms 5216 KB Output is correct
52 Correct 281 ms 4908 KB Output is correct
53 Correct 259 ms 4876 KB Output is correct
54 Correct 274 ms 4860 KB Output is correct
55 Correct 264 ms 4832 KB Output is correct
56 Correct 265 ms 5148 KB Output is correct
57 Incorrect 41 ms 632 KB invalid len
58 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4024 KB Output is correct
2 Correct 5 ms 4408 KB Output is correct
3 Correct 6 ms 3692 KB Output is correct
4 Correct 7 ms 3648 KB Output is correct
5 Correct 7 ms 3964 KB Output is correct
6 Correct 5 ms 3856 KB Output is correct
7 Correct 8 ms 3644 KB Output is correct
8 Correct 8 ms 3632 KB Output is correct
9 Correct 9 ms 4076 KB Output is correct
10 Correct 10 ms 3960 KB Output is correct
11 Correct 9 ms 4088 KB Output is correct
12 Correct 8 ms 4168 KB Output is correct
13 Correct 9 ms 3792 KB Output is correct
14 Correct 17 ms 3920 KB Output is correct
15 Correct 23 ms 3960 KB Output is correct
16 Correct 24 ms 4176 KB Output is correct
17 Correct 24 ms 4652 KB Output is correct
18 Correct 24 ms 4136 KB Output is correct
19 Correct 24 ms 4728 KB Output is correct
20 Correct 23 ms 3896 KB Output is correct
21 Correct 38 ms 4148 KB Output is correct
22 Correct 55 ms 4364 KB Output is correct
23 Correct 52 ms 3820 KB Output is correct
24 Correct 53 ms 4376 KB Output is correct
25 Correct 55 ms 4136 KB Output is correct
26 Correct 55 ms 4488 KB Output is correct
27 Correct 51 ms 4512 KB Output is correct
28 Correct 54 ms 4000 KB Output is correct
29 Correct 75 ms 4696 KB Output is correct
30 Correct 104 ms 4200 KB Output is correct
31 Correct 100 ms 4020 KB Output is correct
32 Correct 102 ms 4568 KB Output is correct
33 Correct 106 ms 4620 KB Output is correct
34 Correct 97 ms 4480 KB Output is correct
35 Correct 108 ms 4216 KB Output is correct
36 Correct 99 ms 4016 KB Output is correct
37 Correct 137 ms 4212 KB Output is correct
38 Correct 178 ms 5032 KB Output is correct
39 Correct 175 ms 4688 KB Output is correct
40 Correct 178 ms 4924 KB Output is correct
41 Correct 166 ms 4600 KB Output is correct
42 Correct 166 ms 4580 KB Output is correct
43 Correct 166 ms 5000 KB Output is correct
44 Correct 173 ms 4592 KB Output is correct
45 Correct 221 ms 5208 KB Output is correct
46 Correct 269 ms 5068 KB Output is correct
47 Correct 275 ms 5448 KB Output is correct
48 Correct 274 ms 4860 KB Output is correct
49 Correct 267 ms 5012 KB Output is correct
50 Correct 285 ms 5128 KB Output is correct
51 Correct 268 ms 5216 KB Output is correct
52 Correct 281 ms 4908 KB Output is correct
53 Correct 259 ms 4876 KB Output is correct
54 Correct 274 ms 4860 KB Output is correct
55 Correct 264 ms 4832 KB Output is correct
56 Correct 265 ms 5148 KB Output is correct
57 Incorrect 41 ms 632 KB invalid len
58 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4024 KB Output is correct
2 Correct 5 ms 4408 KB Output is correct
3 Correct 6 ms 3692 KB Output is correct
4 Correct 7 ms 3648 KB Output is correct
5 Correct 7 ms 3964 KB Output is correct
6 Correct 5 ms 3856 KB Output is correct
7 Correct 8 ms 3644 KB Output is correct
8 Correct 8 ms 3632 KB Output is correct
9 Correct 9 ms 4076 KB Output is correct
10 Correct 10 ms 3960 KB Output is correct
11 Correct 9 ms 4088 KB Output is correct
12 Correct 8 ms 4168 KB Output is correct
13 Correct 9 ms 3792 KB Output is correct
14 Correct 17 ms 3920 KB Output is correct
15 Correct 23 ms 3960 KB Output is correct
16 Correct 24 ms 4176 KB Output is correct
17 Correct 24 ms 4652 KB Output is correct
18 Correct 24 ms 4136 KB Output is correct
19 Correct 24 ms 4728 KB Output is correct
20 Correct 23 ms 3896 KB Output is correct
21 Correct 38 ms 4148 KB Output is correct
22 Correct 55 ms 4364 KB Output is correct
23 Correct 52 ms 3820 KB Output is correct
24 Correct 53 ms 4376 KB Output is correct
25 Correct 55 ms 4136 KB Output is correct
26 Correct 55 ms 4488 KB Output is correct
27 Correct 51 ms 4512 KB Output is correct
28 Correct 54 ms 4000 KB Output is correct
29 Correct 75 ms 4696 KB Output is correct
30 Correct 104 ms 4200 KB Output is correct
31 Correct 100 ms 4020 KB Output is correct
32 Correct 102 ms 4568 KB Output is correct
33 Correct 106 ms 4620 KB Output is correct
34 Correct 97 ms 4480 KB Output is correct
35 Correct 108 ms 4216 KB Output is correct
36 Correct 99 ms 4016 KB Output is correct
37 Correct 137 ms 4212 KB Output is correct
38 Correct 178 ms 5032 KB Output is correct
39 Correct 175 ms 4688 KB Output is correct
40 Correct 178 ms 4924 KB Output is correct
41 Correct 166 ms 4600 KB Output is correct
42 Correct 166 ms 4580 KB Output is correct
43 Correct 166 ms 5000 KB Output is correct
44 Correct 173 ms 4592 KB Output is correct
45 Correct 221 ms 5208 KB Output is correct
46 Correct 269 ms 5068 KB Output is correct
47 Correct 275 ms 5448 KB Output is correct
48 Correct 274 ms 4860 KB Output is correct
49 Correct 267 ms 5012 KB Output is correct
50 Correct 285 ms 5128 KB Output is correct
51 Correct 268 ms 5216 KB Output is correct
52 Correct 281 ms 4908 KB Output is correct
53 Correct 259 ms 4876 KB Output is correct
54 Correct 274 ms 4860 KB Output is correct
55 Correct 264 ms 4832 KB Output is correct
56 Correct 265 ms 5148 KB Output is correct
57 Incorrect 41 ms 632 KB invalid len
58 Halted 0 ms 0 KB -