Submission #537637

# Submission time Handle Problem Language Result Execution time Memory
537637 2022-03-15T10:24:42 Z dantoh000 Hop (COCI21_hop) C++14
0 / 110
1 ms 468 KB
#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++){
            if (i%3 == j%3){
                int x = i-i%3;
                int y = j-j%3;
                while (x%3 == 0 && y%3 == 0){
                    x/=3;
                    y/=3;
                }
                ans[i][j] = c[x%3][y%3];

            }
            else{
                ans[i][j] = c[i%3][j%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);
      |     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Integer 0 violates the range [1, 3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Integer 0 violates the range [1, 3]
2 Halted 0 ms 0 KB -