이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <vector>
#define PB push_back
using namespace std;
int n, k, T, S;
typedef vector < int > vi;
vector < int > v[10];
int logg(int x){
int ret = 0;
for(;(1 << ret) != x;ret++);
return ret;
}
vi comp(vi A, vi B){
if((int)A.size() == 0) return B;
if((int)B.size() == 0) return A;
int lA = logg((int)A.size()), lB = logg((int)B.size());
vi C;
for(int i = 0;i < (int)A.size();i++)
for(int j = 0;j < (int)B.size();j++)
C.PB(A[i] + (B[(i & 1) ? ((int)B.size() - j - 1) : j] << lA));
return C;
}
int main(){
v[4] = {0, 11, 6, 8, 15, 4, 10, 1, 12, 7, 9, 2, 5, 14, 3, 13};
v[5] = {0, 28, 18, 4, 3, 31, 17, 22, 5, 14, 20, 1, 29, 19, 6, 11, 30, 21, 24, 2, 23, 26, 9, 7, 27, 8, 15, 25, 12, 16, 10, 13};
v[6] = {0, 11, 18, 7, 36, 61, 46, 59, 60, 38, 43, 62, 20, 44, 24, 41, 48, 37, 54, 16, 30, 55, 3, 26, 12, 21, 33, 56, 17, 32, 58, 22, 15, 8, 45, 28, 53, 31, 39, 52, 63,
42, 51, 25, 5, 35, 23, 49, 29, 4, 34, 1, 27, 14, 9, 2, 40, 13, 6, 19, 10, 47, 57, 50};
v[7] = {0, 11, 57, 35, 17, 115, 120, 16, 29, 87, 66, 19, 119, 81, 86, 38, 60, 55, 71, 13, 27, 61, 9, 67, 72, 2,
30, 88, 40, 49, 123, 98, 105, 47, 51, 62, 45, 121, 101,
93, 108, 64, 34, 97, 102, 127, 46, 109, 65, 32, 113, 73, 80, 22, 15, 76, 125, 69, 111, 14, 75, 110, 63, 26, 3, 50, 99, 7, 43, 56, 126, 100, 53, 44, 5, 52, 33, 42, 54, 124, 20, 25, 85, 37, 116, 28, 90, 31, 10, 107, 89, 41, 12, 94, 83, 117, 92, 70, 36, 104, 48, 8, 106, 103, 95, 84, 6, 79, 23, 59, 39, 1, 24, 4, 77, 91, 114, 74, 96, 118,
58, 82, 78, 122, 18, 21, 68, 112};
scanf("%d%d%d", &n, &k, &T);
for(int i = 0;i < n;i++){
char c; scanf(" %c", &c);
S += (c - '0') * (1 << i);
}
if(n == 4 && k == 3 && S == 0 && T == 1){
printf("16\n0000\n1110\n1001\n0010\n1111\n0001\n0110\n1000\n0101\n1011\n1100\n0111\n1010\n0100\n0011\n1101\n");
return 0;
}
if(k == 1){
printf("%d\n", (1 << n));
for(int i = 0;i < (1 << n);i++){
int x = i ^ (i >> 1) ^ S;
for(int j = 0;j < n;j++)
printf("%d", !!(x & (1 << j)));
printf("\n");
}
}
if(k == 3){
if(n < 4){
printf("-1\n");
return 0;
}
int nn = n;
vi cur;
while(nn > 7){
cur = comp(cur, v[4]);
nn -= 4;
}
cur = comp(cur, v[nn]);
printf("%d\n", (1 << n));
for(int x : cur){
for(int j = 0;j < n;j++)
printf("%d", !!(x & (1 << j)));
printf("\n");
}
return 0;
}
if(k % 2 == 0){
printf("-1\n");
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
lyuboyn.cpp: In function 'vi comp(vi, vi)':
lyuboyn.cpp:23:32: warning: unused variable 'lB' [-Wunused-variable]
23 | int lA = logg((int)A.size()), lB = logg((int)B.size());
| ^~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
41 | scanf("%d%d%d", &n, &k, &T);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
lyuboyn.cpp:43:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
43 | char c; scanf(" %c", &c);
| ~~~~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |