답안 #415623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
415623 2021-06-01T09:51:35 Z qwerasdfzxcl Vision Program (IOI19_vision) C++14
100 / 100
25 ms 2004 KB
#include <bits/stdc++.h>
#include "vision.h"

typedef long long ll;
using namespace std;
vector<int> p;
int factor[202];
bool prime[202];

void getprime(){
    fill(prime+2, prime+202, 1);
    for (int i=2;i<202;i++) if (prime[i]){
        p.push_back(i);
        for (int j=2;i*j<202;j++) prime[i*j] = 0;
    }
}

void factorize(int n){
    fill(factor, factor+202, 0);
    for (auto &x:p){
        while(n%x==0){
            factor[x]++;
            n /= x;
        }
    }
}

void construct_network(int n, int m, int k) {
    getprime();
    vector<int> row;
    for (int i=0;i<n;i++){
        vector<int> tmp;
        for (int j=0;j<m;j++) tmp.push_back(i*m+j);
        row.push_back(add_or(tmp));
    }
    int row_pos0 = add_xor(row);
    vector<vector<int>> row_pk;
    row_pk.resize(n);
    for (int i=0;i<n;i++){
        row_pk[i].push_back(-1);
        if (!prime[i]) continue;
        for (int cur=i;cur<n;cur*=i){
            vector<int> tmp2;
            for (int t=0;t<cur;t++){
                vector<int> tmp;
                for (int j=0;t+cur*j<n;j++) tmp.push_back(row[t+cur*j]);
                if (tmp.size()==1){
                    tmp2.push_back(tmp[0]);
                    continue;
                }
                tmp2.push_back(add_xor(tmp));
            }
            row_pk[i].push_back(add_not(add_or(tmp2)));
            add_not(row_pk[i].back());
        }
    }
    row_pk[0][0] = row_pos0;
    vector<int> tmpv_row;
    tmpv_row.push_back(row_pos0);
    for (int i=2;i<n;i++){
        factorize(i);
        vector<int> tmp;
        for (auto &x:p){
            if (x>=n) break;
            if (factor[x]) tmp.push_back(row_pk[x][factor[x]]);
            if (factor[x]<(int)row_pk[x].size()-1) tmp.push_back(row_pk[x][factor[x]+1]+1);
        }
        row_pk[i][0] = add_and(tmp);
        tmpv_row.push_back(row_pk[i][0]);
    }
    if (n>1) row_pk[1][0] = add_not(add_or(tmpv_row));



    vector<int> col;
    for (int j=0;j<m;j++){
        vector<int> tmp;
        for (int i=0;i<n;i++) tmp.push_back(i*m+j);
        col.push_back(add_or(tmp));
    }
    int col_pos0 = add_xor(col);
    vector<vector<int>> col_pk;
    col_pk.resize(m);
    for (int j=0;j<m;j++){
        col_pk[j].push_back(-1);
        if (!prime[j]) continue;
        for (int cur=j;cur<m;cur*=j){
            vector<int> tmp2;
            for (int t=0;t<cur;t++){
                vector<int> tmp;
                for (int i=0;t+i*cur<m;i++) tmp.push_back(col[t+i*cur]);
                if (tmp.size()==1){
                    tmp2.push_back(tmp[0]);
                    continue;
                }
                tmp2.push_back(add_xor(tmp));
            }
            col_pk[j].push_back(add_not(add_or(tmp2)));
            add_not(col_pk[j].back());
        }
    }
    col_pk[0][0] = col_pos0;
    vector<int> tmpv_col;
    tmpv_col.push_back(col_pos0);
    for (int j=2;j<m;j++){
        factorize(j);
        vector<int> tmp;
        for (auto &x:p){
            if (x>=m) break;
            if (factor[x]) tmp.push_back(col_pk[x][factor[x]]);
            if (factor[x]<(int)col_pk[x].size()-1) tmp.push_back(col_pk[x][factor[x]+1]+1);
        }
        col_pk[j][0] = add_and(tmp);
        tmpv_col.push_back(col_pk[j][0]);
    }
    if (m>1) col_pk[1][0] = add_not(add_or(tmpv_col));

    vector<int> ans;
    for (int i=0;i<=k;i++){
        if (i>=n || k-i>=m) continue;
        vector<int> tmp;
        tmp.push_back(row_pk[i][0]);
        tmp.push_back(col_pk[k-i][0]);
        ans.push_back(add_and(tmp));
    }
    add_or(ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 292 KB Output is correct
24 Correct 1 ms 292 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 292 KB Output is correct
24 Correct 1 ms 292 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 292 KB Output is correct
24 Correct 1 ms 292 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 6 ms 808 KB Output is correct
39 Correct 3 ms 332 KB Output is correct
40 Correct 2 ms 416 KB Output is correct
41 Correct 5 ms 460 KB Output is correct
42 Correct 4 ms 460 KB Output is correct
43 Correct 8 ms 804 KB Output is correct
44 Correct 9 ms 716 KB Output is correct
45 Correct 8 ms 716 KB Output is correct
46 Correct 6 ms 716 KB Output is correct
47 Correct 6 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 588 KB Output is correct
2 Correct 5 ms 716 KB Output is correct
3 Correct 5 ms 588 KB Output is correct
4 Correct 6 ms 716 KB Output is correct
5 Correct 7 ms 684 KB Output is correct
6 Correct 6 ms 716 KB Output is correct
7 Correct 5 ms 716 KB Output is correct
8 Correct 5 ms 716 KB Output is correct
9 Correct 5 ms 716 KB Output is correct
10 Correct 5 ms 716 KB Output is correct
11 Correct 5 ms 716 KB Output is correct
12 Correct 5 ms 716 KB Output is correct
13 Correct 5 ms 716 KB Output is correct
14 Correct 7 ms 676 KB Output is correct
15 Correct 5 ms 716 KB Output is correct
16 Correct 5 ms 676 KB Output is correct
17 Correct 5 ms 676 KB Output is correct
18 Correct 5 ms 716 KB Output is correct
19 Correct 6 ms 716 KB Output is correct
20 Correct 6 ms 716 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 4 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 5 ms 720 KB Output is correct
9 Correct 6 ms 716 KB Output is correct
10 Correct 7 ms 716 KB Output is correct
11 Correct 5 ms 716 KB Output is correct
12 Correct 7 ms 588 KB Output is correct
13 Correct 5 ms 716 KB Output is correct
14 Correct 5 ms 716 KB Output is correct
15 Correct 6 ms 672 KB Output is correct
16 Correct 5 ms 588 KB Output is correct
17 Correct 5 ms 716 KB Output is correct
18 Correct 5 ms 716 KB Output is correct
19 Correct 5 ms 680 KB Output is correct
20 Correct 12 ms 1224 KB Output is correct
21 Correct 13 ms 1276 KB Output is correct
22 Correct 11 ms 1224 KB Output is correct
23 Correct 11 ms 1224 KB Output is correct
24 Correct 11 ms 1196 KB Output is correct
25 Correct 12 ms 1208 KB Output is correct
26 Correct 11 ms 1224 KB Output is correct
27 Correct 19 ms 1904 KB Output is correct
28 Correct 19 ms 1948 KB Output is correct
29 Correct 19 ms 1856 KB Output is correct
30 Correct 19 ms 1864 KB Output is correct
31 Correct 19 ms 1864 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1864 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 4 ms 460 KB Output is correct
4 Correct 5 ms 716 KB Output is correct
5 Correct 6 ms 588 KB Output is correct
6 Correct 7 ms 688 KB Output is correct
7 Correct 11 ms 1196 KB Output is correct
8 Correct 11 ms 1224 KB Output is correct
9 Correct 24 ms 1888 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 292 KB Output is correct
24 Correct 1 ms 292 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 6 ms 808 KB Output is correct
39 Correct 3 ms 332 KB Output is correct
40 Correct 2 ms 416 KB Output is correct
41 Correct 5 ms 460 KB Output is correct
42 Correct 4 ms 460 KB Output is correct
43 Correct 8 ms 804 KB Output is correct
44 Correct 9 ms 716 KB Output is correct
45 Correct 8 ms 716 KB Output is correct
46 Correct 6 ms 716 KB Output is correct
47 Correct 6 ms 716 KB Output is correct
48 Correct 5 ms 588 KB Output is correct
49 Correct 5 ms 716 KB Output is correct
50 Correct 5 ms 588 KB Output is correct
51 Correct 6 ms 716 KB Output is correct
52 Correct 7 ms 684 KB Output is correct
53 Correct 6 ms 716 KB Output is correct
54 Correct 5 ms 716 KB Output is correct
55 Correct 5 ms 716 KB Output is correct
56 Correct 5 ms 716 KB Output is correct
57 Correct 5 ms 716 KB Output is correct
58 Correct 5 ms 716 KB Output is correct
59 Correct 5 ms 716 KB Output is correct
60 Correct 5 ms 716 KB Output is correct
61 Correct 7 ms 676 KB Output is correct
62 Correct 5 ms 716 KB Output is correct
63 Correct 5 ms 676 KB Output is correct
64 Correct 5 ms 676 KB Output is correct
65 Correct 5 ms 716 KB Output is correct
66 Correct 6 ms 716 KB Output is correct
67 Correct 6 ms 716 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 292 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 3 ms 460 KB Output is correct
73 Correct 3 ms 460 KB Output is correct
74 Correct 4 ms 460 KB Output is correct
75 Correct 3 ms 460 KB Output is correct
76 Correct 4 ms 460 KB Output is correct
77 Correct 5 ms 720 KB Output is correct
78 Correct 6 ms 716 KB Output is correct
79 Correct 7 ms 716 KB Output is correct
80 Correct 5 ms 716 KB Output is correct
81 Correct 7 ms 588 KB Output is correct
82 Correct 5 ms 716 KB Output is correct
83 Correct 5 ms 716 KB Output is correct
84 Correct 6 ms 672 KB Output is correct
85 Correct 5 ms 588 KB Output is correct
86 Correct 5 ms 716 KB Output is correct
87 Correct 5 ms 716 KB Output is correct
88 Correct 5 ms 680 KB Output is correct
89 Correct 12 ms 1224 KB Output is correct
90 Correct 13 ms 1276 KB Output is correct
91 Correct 11 ms 1224 KB Output is correct
92 Correct 11 ms 1224 KB Output is correct
93 Correct 11 ms 1196 KB Output is correct
94 Correct 12 ms 1208 KB Output is correct
95 Correct 11 ms 1224 KB Output is correct
96 Correct 19 ms 1904 KB Output is correct
97 Correct 19 ms 1948 KB Output is correct
98 Correct 19 ms 1856 KB Output is correct
99 Correct 19 ms 1864 KB Output is correct
100 Correct 19 ms 1864 KB Output is correct
101 Correct 1 ms 204 KB Output is correct
102 Correct 1 ms 288 KB Output is correct
103 Correct 19 ms 1864 KB Output is correct
104 Correct 1 ms 204 KB Output is correct
105 Correct 4 ms 460 KB Output is correct
106 Correct 5 ms 716 KB Output is correct
107 Correct 6 ms 588 KB Output is correct
108 Correct 7 ms 688 KB Output is correct
109 Correct 11 ms 1196 KB Output is correct
110 Correct 11 ms 1224 KB Output is correct
111 Correct 24 ms 1888 KB Output is correct
112 Correct 1 ms 204 KB Output is correct
113 Correct 1 ms 204 KB Output is correct
114 Correct 19 ms 2004 KB Output is correct
115 Correct 5 ms 676 KB Output is correct
116 Correct 5 ms 588 KB Output is correct
117 Correct 15 ms 1188 KB Output is correct
118 Correct 13 ms 1224 KB Output is correct
119 Correct 20 ms 1996 KB Output is correct
120 Correct 18 ms 1880 KB Output is correct
121 Correct 18 ms 1908 KB Output is correct
122 Correct 19 ms 1864 KB Output is correct
123 Correct 25 ms 1852 KB Output is correct
124 Correct 20 ms 1880 KB Output is correct
125 Correct 22 ms 1992 KB Output is correct
126 Correct 18 ms 1932 KB Output is correct
127 Correct 18 ms 1924 KB Output is correct
128 Correct 19 ms 1864 KB Output is correct