#include <bits/stdc++.h>
using namespace std;
int n;
int a[1005];
int c[3][3];
int ans[1005][1005];
vector<int> G[3][1005];
int d[3][1005];
void dfs(int u, int c){
for (auto v : G[c][u]){
d[c][v] = d[c][u]+1;
dfs(v,c);
}
}
int main(){
scanf("%d",&n);
//for (int i = 0; i < n; i++){
// scanf("%d",&a[i]);
//}
c[0][1] = 1;
c[0][2] = 2;
c[1][0] = 3;
c[1][2] = 2;
c[2][0] = 3;
c[2][1] = 1;
for (int i = 0; i < n; i++){
for (int j = 0; j < i; j++){
int x = i;
int y = j;
while (!(x == 0 && y == 0) && x%3 == y%3){
x -= x%3;
y -= y%3;
while (!(x == 0 && y == 0) && x%3 == 0 && y%3 == 0){
//printf("%d %d\n",x,y);
x/=3;
y/=3;
}
}
//printf("final %d %d\n",x,y);
ans[i][j] = c[x%3][y%3];
}
}
/*
for (int i = 0; i < n; i++){
for (int j = 0; j < i; j++){
G[c[i][j]][i].push_back(j);
}
}
for (int i = 1; i <= 3; i++){
for (int j = n-1; j >= 0; j--){
if (d[i][j] == 0) dfs(j,i);
}
}
for (int i = 1; i <= 3; i++){
for (int j = 0; j < n; j++){
printf("%d ",d[i][j]);
}
printf("\n");
}*/
for (int i = 0; i < n; i++){
for (int j = 0; j < i; j++){
printf("%d ",ans[i][j]);
}
printf("\n");
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
59 ms |
5296 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Correct |
34 ms |
4700 KB |
Output is correct |
12 |
Correct |
43 ms |
5280 KB |
Output is correct |
13 |
Correct |
39 ms |
4924 KB |
Output is correct |
14 |
Correct |
3 ms |
1108 KB |
Output is correct |
15 |
Correct |
36 ms |
4812 KB |
Output is correct |
16 |
Correct |
38 ms |
4940 KB |
Output is correct |
17 |
Correct |
37 ms |
4884 KB |
Output is correct |
18 |
Correct |
41 ms |
4904 KB |
Output is correct |
19 |
Correct |
35 ms |
4864 KB |
Output is correct |
20 |
Correct |
36 ms |
4940 KB |
Output is correct |
21 |
Correct |
35 ms |
4880 KB |
Output is correct |
22 |
Correct |
52 ms |
4888 KB |
Output is correct |
23 |
Correct |
42 ms |
5244 KB |
Output is correct |