답안 #238425

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238425 2020-06-11T07:54:06 Z Ruxandra985 Vision Program (IOI19_vision) C++14
100 / 100
94 ms 8948 KB
#include <bits/stdc++.h>
#include <cassert>
#include <string>
#include "vision.h"
 
 
using namespace std;
 
 
/// ---------------------------------------------------------------------------------
 
int res[1000010] , f[210][210];
int sau_pr[510] , sau_sec[510] , xor_pr[510] , xor_sec[510];
 
int convert (int x , int y , int n , int m){
 
    return (x - 1) * m + y - 1;
 
}
 
int in_matrix (int i , int j , int n , int m){
 
    return (i > 0 && j > 0 && i <= n && j <= m);
 
}
 
 
void construct_network(int n, int m, int k) {
 
    int i , j , dif , dif2 , sum , sum2 , princ , sec , rez1 , rez2 , cod_diag , p1 , p2;
    vector <int> v , w , x;
    for (dif = 1 - m ; dif <= n - 1 ; dif++){
 
        v.clear();
 
        for (i = 1 ; i <= n ; i++){
 
            /// i - j = dif
            j = i - dif;
 
            if (in_matrix(i , j , n , m)){ /// e o pozitie valida de pe diagonala asta
 
                v.push_back(convert(i , j , n , m));
 
            }
 
 
        }
 
 
        /// in v ai elem de pe diag
        cod_diag = dif - (1 - m);
        sau_pr[cod_diag] = add_or(v);
        xor_pr[cod_diag] = add_xor(v);
 
    }
    w.clear();
    for (dif = 1 - m ; dif <= n - 1 ; dif++){
        v.clear();
        x.clear();
 
        if (dif + k > n - 1)
            continue;
 
        for (dif2 = dif ; dif2 <= n - 1 && dif2 <= dif + k ; dif2++){
 
            /// vad intervalul dif , dif2
            v.push_back(sau_pr[dif2 - (1 - m)]);
            x.push_back(xor_pr[dif2 - (1 - m)]);
        }
 
 
        p1 = add_or(v);
        p2 = add_xor(x);
 
        v.clear();
        v.push_back(p1);
        v.push_back(p2);
 
        w.push_back(add_xor(v));
 
    }
 
    princ = add_or(w);
 
 
    /// pe princ trb sa fie 1
    /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
    for (sum = n + m ; sum >= 2 ; sum--){
 
        v.clear();
 
        for (i = 1 ; i <= n ; i++){
 
            /// i + j = sum
            j = - (i - sum);
 
            if (in_matrix(i , j , n , m)){ /// e o pozitie valida de pe diagonala asta
 
                v.push_back(convert(i , j , n , m));
 
            }
 
 
        }
 
        /// in v ai elem de pe diag
        cod_diag = sum;
        sau_sec[cod_diag] = add_or(v);
        xor_sec[cod_diag] = add_xor(v);
 
    }
 
    w.clear();
    for (sum = n + m ; sum >= 2 ; sum--){
        v.clear();
        x.clear();
 
        for (sum2 = sum ; sum2 >= 2 && sum - sum2 <= k ; sum2--){
 
            /// vad intervalul sum , sum2
            v.push_back(sau_sec[sum2]);
            x.push_back(xor_sec[sum2]);
        }
 
        p1 = add_or(v);
        p2 = add_xor(x);
 
        v.clear();
        v.push_back(p1);
        v.push_back(p2);
 
        w.push_back(add_xor(v));
 
    }
 
    sec = add_or(w);
 
    v.clear();
    v.push_back(princ);
    v.push_back(sec);
 
    rez1 = add_and(v);
    if (k == 1)
        return;
 
    /// ----------------------------------------------------------------------------
 
 
    for (dif = 1 - m ; dif <= n - 1 ; dif++){
 
        v.clear();
 
        for (i = 1 ; i <= n ; i++){
 
            /// i - j = dif
            j = i - dif;
 
            if (in_matrix(i , j , n , m)){ /// e o pozitie valida de pe diagonala asta
 
                v.push_back(convert(i , j , n , m));
 
            }
 
 
        }
 
        /// in v ai elem de pe diag
        cod_diag = dif - (1 - m);
        sau_pr[cod_diag] = add_or(v);
        xor_pr[cod_diag] = add_xor(v);
 
    }
    w.clear();
    for (dif = 1 - m ; dif <= n - 1 ; dif++){
        v.clear();
        x.clear();
 
        for (dif2 = dif ; dif2 <= n - 1 && dif2 < dif + k ; dif2++){
 
            /// vad intervalul dif , dif2
            v.push_back(sau_pr[dif2 - (1 - m)]);
            x.push_back(xor_pr[dif2 - (1 - m)]);
        }
 
        p1 = add_or(v);
        p2 = add_xor(x);
 
        v.clear();
        v.push_back(p1);
        v.push_back(p2);
 
        w.push_back(add_xor(v));
 
    }
 
    princ = add_or(w);
    /// pe princ trb sa fie 1
    /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
    for (sum = n + m ; sum >= 2 ; sum--){
 
        v.clear();
 
        for (i = 1 ; i <= n ; i++){
 
            /// i + j = sum
            j = - (i - sum);
 
            if (in_matrix(i , j , n , m)){ /// e o pozitie valida de pe diagonala asta
 
                v.push_back(convert(i , j , n , m));
 
            }
 
 
        }
 
        /// in v ai elem de pe diag
        cod_diag = sum;
        sau_sec[cod_diag] = add_or(v);
        xor_sec[cod_diag] = add_xor(v);
 
    }
    w.clear();
    for (sum = n + m ; sum >= 2 ; sum--){
        v.clear();
        x.clear();
 
        for (sum2 = sum ; sum2 >= 2 && sum - sum2 < k ; sum2--){
 
            /// vad intervalul sum , sum2
            v.push_back(sau_sec[sum2]);
            x.push_back(xor_sec[sum2]);
        }
 
        p1 = add_or(v);
        p2 = add_xor(x);
 
        v.clear();
        v.push_back(p1);
        v.push_back(p2);
 
        w.push_back(add_xor(v));
 
    }
 
 
 
    sec = add_or(w);
 
    v.clear();
    v.push_back(princ);
    v.push_back(sec);
 
    rez2 = add_and(v);
 
 
    rez2 = add_not(rez2);
 
    v.clear();
    v.push_back(rez1);
    v.push_back(rez2);
    add_and(v);
 
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 6 ms 512 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 6 ms 512 KB Output is correct
35 Correct 7 ms 640 KB Output is correct
36 Correct 7 ms 512 KB Output is correct
37 Correct 7 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 6 ms 512 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 6 ms 512 KB Output is correct
35 Correct 7 ms 640 KB Output is correct
36 Correct 7 ms 512 KB Output is correct
37 Correct 7 ms 512 KB Output is correct
38 Correct 21 ms 1920 KB Output is correct
39 Correct 7 ms 640 KB Output is correct
40 Correct 9 ms 768 KB Output is correct
41 Correct 12 ms 896 KB Output is correct
42 Correct 17 ms 1536 KB Output is correct
43 Correct 10 ms 896 KB Output is correct
44 Correct 21 ms 1920 KB Output is correct
45 Correct 25 ms 2304 KB Output is correct
46 Correct 27 ms 2560 KB Output is correct
47 Correct 26 ms 2432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 17 ms 1536 KB Output is correct
3 Correct 17 ms 1536 KB Output is correct
4 Correct 18 ms 1664 KB Output is correct
5 Correct 7 ms 640 KB Output is correct
6 Correct 15 ms 1280 KB Output is correct
7 Correct 19 ms 1664 KB Output is correct
8 Correct 20 ms 1664 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 14 ms 1152 KB Output is correct
11 Correct 17 ms 1536 KB Output is correct
12 Correct 18 ms 1536 KB Output is correct
13 Correct 19 ms 1664 KB Output is correct
14 Correct 18 ms 1664 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 14 ms 1152 KB Output is correct
17 Correct 17 ms 1536 KB Output is correct
18 Correct 18 ms 1536 KB Output is correct
19 Correct 19 ms 1664 KB Output is correct
20 Correct 19 ms 1664 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 7 ms 512 KB Output is correct
4 Correct 11 ms 984 KB Output is correct
5 Correct 13 ms 1152 KB Output is correct
6 Correct 13 ms 1280 KB Output is correct
7 Correct 13 ms 1152 KB Output is correct
8 Correct 8 ms 640 KB Output is correct
9 Correct 16 ms 1408 KB Output is correct
10 Correct 20 ms 1792 KB Output is correct
11 Correct 23 ms 1792 KB Output is correct
12 Correct 20 ms 1792 KB Output is correct
13 Correct 6 ms 512 KB Output is correct
14 Correct 14 ms 1280 KB Output is correct
15 Correct 19 ms 1664 KB Output is correct
16 Correct 18 ms 1664 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 18 ms 1536 KB Output is correct
19 Correct 19 ms 1664 KB Output is correct
20 Correct 14 ms 1280 KB Output is correct
21 Correct 41 ms 4084 KB Output is correct
22 Correct 52 ms 4980 KB Output is correct
23 Correct 54 ms 4852 KB Output is correct
24 Correct 14 ms 1408 KB Output is correct
25 Correct 47 ms 4596 KB Output is correct
26 Correct 55 ms 4852 KB Output is correct
27 Correct 24 ms 2176 KB Output is correct
28 Correct 68 ms 6516 KB Output is correct
29 Correct 85 ms 8180 KB Output is correct
30 Correct 92 ms 8948 KB Output is correct
31 Correct 90 ms 8692 KB Output is correct
32 Correct 4 ms 384 KB Output is correct
33 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2176 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 8 ms 640 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 14 ms 1280 KB Output is correct
8 Correct 15 ms 1280 KB Output is correct
9 Correct 23 ms 2176 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 6 ms 512 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 6 ms 512 KB Output is correct
35 Correct 7 ms 640 KB Output is correct
36 Correct 7 ms 512 KB Output is correct
37 Correct 7 ms 512 KB Output is correct
38 Correct 21 ms 1920 KB Output is correct
39 Correct 7 ms 640 KB Output is correct
40 Correct 9 ms 768 KB Output is correct
41 Correct 12 ms 896 KB Output is correct
42 Correct 17 ms 1536 KB Output is correct
43 Correct 10 ms 896 KB Output is correct
44 Correct 21 ms 1920 KB Output is correct
45 Correct 25 ms 2304 KB Output is correct
46 Correct 27 ms 2560 KB Output is correct
47 Correct 26 ms 2432 KB Output is correct
48 Correct 5 ms 512 KB Output is correct
49 Correct 17 ms 1536 KB Output is correct
50 Correct 17 ms 1536 KB Output is correct
51 Correct 18 ms 1664 KB Output is correct
52 Correct 7 ms 640 KB Output is correct
53 Correct 15 ms 1280 KB Output is correct
54 Correct 19 ms 1664 KB Output is correct
55 Correct 20 ms 1664 KB Output is correct
56 Correct 6 ms 512 KB Output is correct
57 Correct 14 ms 1152 KB Output is correct
58 Correct 17 ms 1536 KB Output is correct
59 Correct 18 ms 1536 KB Output is correct
60 Correct 19 ms 1664 KB Output is correct
61 Correct 18 ms 1664 KB Output is correct
62 Correct 6 ms 512 KB Output is correct
63 Correct 14 ms 1152 KB Output is correct
64 Correct 17 ms 1536 KB Output is correct
65 Correct 18 ms 1536 KB Output is correct
66 Correct 19 ms 1664 KB Output is correct
67 Correct 19 ms 1664 KB Output is correct
68 Correct 5 ms 384 KB Output is correct
69 Correct 4 ms 384 KB Output is correct
70 Correct 5 ms 384 KB Output is correct
71 Correct 4 ms 384 KB Output is correct
72 Correct 7 ms 512 KB Output is correct
73 Correct 11 ms 984 KB Output is correct
74 Correct 13 ms 1152 KB Output is correct
75 Correct 13 ms 1280 KB Output is correct
76 Correct 13 ms 1152 KB Output is correct
77 Correct 8 ms 640 KB Output is correct
78 Correct 16 ms 1408 KB Output is correct
79 Correct 20 ms 1792 KB Output is correct
80 Correct 23 ms 1792 KB Output is correct
81 Correct 20 ms 1792 KB Output is correct
82 Correct 6 ms 512 KB Output is correct
83 Correct 14 ms 1280 KB Output is correct
84 Correct 19 ms 1664 KB Output is correct
85 Correct 18 ms 1664 KB Output is correct
86 Correct 6 ms 512 KB Output is correct
87 Correct 18 ms 1536 KB Output is correct
88 Correct 19 ms 1664 KB Output is correct
89 Correct 14 ms 1280 KB Output is correct
90 Correct 41 ms 4084 KB Output is correct
91 Correct 52 ms 4980 KB Output is correct
92 Correct 54 ms 4852 KB Output is correct
93 Correct 14 ms 1408 KB Output is correct
94 Correct 47 ms 4596 KB Output is correct
95 Correct 55 ms 4852 KB Output is correct
96 Correct 24 ms 2176 KB Output is correct
97 Correct 68 ms 6516 KB Output is correct
98 Correct 85 ms 8180 KB Output is correct
99 Correct 92 ms 8948 KB Output is correct
100 Correct 90 ms 8692 KB Output is correct
101 Correct 4 ms 384 KB Output is correct
102 Correct 4 ms 384 KB Output is correct
103 Correct 25 ms 2176 KB Output is correct
104 Correct 4 ms 384 KB Output is correct
105 Correct 6 ms 512 KB Output is correct
106 Correct 8 ms 640 KB Output is correct
107 Correct 6 ms 512 KB Output is correct
108 Correct 6 ms 512 KB Output is correct
109 Correct 14 ms 1280 KB Output is correct
110 Correct 15 ms 1280 KB Output is correct
111 Correct 23 ms 2176 KB Output is correct
112 Correct 4 ms 384 KB Output is correct
113 Correct 4 ms 384 KB Output is correct
114 Correct 68 ms 6644 KB Output is correct
115 Correct 18 ms 1664 KB Output is correct
116 Correct 7 ms 640 KB Output is correct
117 Correct 59 ms 4980 KB Output is correct
118 Correct 34 ms 3316 KB Output is correct
119 Correct 94 ms 8208 KB Output is correct
120 Correct 88 ms 8180 KB Output is correct
121 Correct 87 ms 8180 KB Output is correct
122 Correct 83 ms 8180 KB Output is correct
123 Correct 23 ms 2176 KB Output is correct
124 Correct 65 ms 6516 KB Output is correct
125 Correct 83 ms 8308 KB Output is correct
126 Correct 85 ms 8180 KB Output is correct
127 Correct 92 ms 8948 KB Output is correct
128 Correct 87 ms 8564 KB Output is correct