QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#182442#6643. Graphs and Colorsucup-team134RE 4ms3972kbC++143.0kb2023-09-18 01:17:432023-09-18 01:17:43

Judging History

你现在查看的是最新测评结果

  • [2023-09-18 01:17:43]
  • 评测
  • 测评结果:RE
  • 用时:4ms
  • 内存:3972kb
  • [2023-09-18 01:17:43]
  • 提交

answer

#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define ll long long
using namespace std;
typedef pair<int,int> pii;

const int mod=998244353;
inline int add(int x,int y){int ret=x+y;if(ret>=mod)ret-=mod;return ret;}
inline int sub(int x,int y){int ret=x-y;if(ret<0)ret+=mod;return ret;}
inline int mul(int x,int y){return ((ll)x*y)%mod;}
inline int step(int base,int pw){int ret=1;while(pw){if(pw&1)ret=mul(ret,base);base=mul(base,base);pw>>=1;}return ret;}
inline int invv(int x){return step(x,mod-2);}

const int maxn=110;

int adj[maxn][maxn];
int p[50][maxn],cc[50];

int root(int x,int pp){
    if(x==p[pp][x])return p[pp][x];
    return p[pp][x]=root(p[pp][x],pp);
}
void join(int x,int y,int pp){
    x=root(x,pp);
    y=root(y,pp);
    if(x==y)return;
    p[pp][x]=y;
    cc[pp]--;
}

void build(int n){

    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)adj[i][j]=0;

    if(n%2==0){

        for(int i=1;i<=n/2;i++){

            int nd=n/2+i;

            adj[i][nd]=i;
            adj[nd][i]=i;

            for(int j=i;j<=n/2;j++){
                adj[i][n/2+j]=i;
                adj[n/2+j][i]=i;

                adj[nd][j]=i;
                adj[j][nd]=i;
            }
            for(int j=1;j<=i;j++){
                adj[i][j]=i;
                adj[j][i]=i;

                adj[nd][j+n/2]=i;
                adj[j+n/2][nd]=i;
            }

        }

    }
    else{
        n--;
        for(int i=1;i<=n/2;i++){

            int nd=n/2+i;

            adj[i][nd]=i;
            adj[nd][i]=i;
            adj[i][n+1]=i;
            adj[n+1][i]=i;
            adj[nd][n+1]=i;
            adj[n+1][nd]=i;

            for(int j=i;j<=n/2;j++){
                adj[i][n/2+j]=i;
                adj[n/2+j][i]=i;

                adj[nd][j]=i;
                adj[j][nd]=i;
            }
            for(int j=1;j<=i;j++){
                adj[i][j]=i;
                adj[j][i]=i;

                adj[nd][j+n/2]=i;
                adj[j+n/2][nd]=i;
            }

        }


    }

}

int main(){

    ///freopen("test.txt","r",stdin);

    int t;
    scanf("%d",&t);
    int pt=0;
    while(t--){

        pt++;

        int n,k;
        scanf("%d %d",&n,&k);

        /*if(pt==52){
            printf("%d %d TC\n",n,k);
            continue;
        }*/

        for(int i=1;i<=k;i++){
            for(int j=1;j<=n;j++){
                cc[i]=n;
                p[i][j]=j;
            }
        }

        build(n);
        //continue;
        if(k>n/2){
            printf("NO\n");
            continue;
        }
        printf("YES\n");
        for(int i=2;i<=n;i++){
            for(int j=1;j<i;j++){
                //join(i,j,adj[i][j]);
                printf("%d ",max(1,min(k,adj[i][j])) );
                //printf("%d ",adj[i][j] );
            }
            printf("\n");
        }

        //for(int i=1;i<=k;i++){
            //printf("%d %d CC\n",i,cc[i]);
        //}

    }


    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3864kb

input:

768
8 24
7 20
17 61
17 76
16 100
16 16
15 59
9 17
14 31
14 61
10 32
17 55
5 7
10 29
14 82
13 47
17 32
5 10
16 76
14 59
8 28
13 19
12 41
13 41
11 32
11 53
3 2
16 52
16 87
7 12
9 15
15 65
15 53
17 47
6 15
12 1
14 35
16 60
12 31
14 70
15 88
12 2
8 23
12 38
16 111
16 117
5 4
14 90
12 55
15 41
15 48
15 4...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
1 
1 1 
1 1 1 
1 1 1 1 
1 1 1 1 1 
1 1 1 1 1 1 
1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 1 
NO
NO
NO
NO
NO
YES
2 
2 2 
2 2 2 
2 2 2 2 
2 2 2...

result:

ok t=768 (768 test cases)

Test #2:

score: 0
Accepted
time: 4ms
memory: 3972kb

input:

350
17 100
30 16
18 42
18 31
17 133
18 21
52 26
28 14
18 71
18 2
52 27
42 22
88 44
37 18
18 72
80 40
18 133
18 69
40 21
16 9
17 99
51 26
17 111
97 48
17 96
18 142
18 9
18 10
18 84
14 8
18 30
61 30
18 122
7 3
74 37
18 16
17 89
17 101
36 18
84 42
4 2
68 34
18 126
79 39
23 12
63 31
18 81
32 16
18 143
1...

output:

NO
NO
NO
NO
NO
NO
YES
2 
3 3 
4 4 4 
5 5 5 5 
6 6 6 6 6 
7 7 7 7 7 7 
8 8 8 8 8 8 8 
9 9 9 9 9 9 9 9 
10 10 10 10 10 10 10 10 10 
11 11 11 11 11 11 11 11 11 11 
12 12 12 12 12 12 12 12 12 12 12 
13 13 13 13 13 13 13 13 13 13 13 13 
14 14 14 14 14 14 14 14 14 14 14 14 14 
15 15 15 15 15 15 15 15 15 1...

result:

ok t=350 (350 test cases)

Test #3:

score: -100
Runtime Error

input:

173
67 32
29 13
37 17
60 31
72 35
92 45
90 44
45 6
45 7
36 17
76 37
10 4
6 2
45 943
9 3
79 38
83 42
45 982
45 483
88 43
91 46
45 1
20 9
96 49
80 39
55 26
48 23
65 33
89 43
41 19
84 43
63 30
88 45
98 50
50 24
15 6
100 49
93 47
49 23
97 47
96 47
45 818
45 3
45 703
22 10
23 10
46 22
7 2
65 31
28 13
83 ...

output:

YES
2 
3 3 
4 4 4 
5 5 5 5 
6 6 6 6 6 
7 7 7 7 7 7 
8 8 8 8 8 8 8 
9 9 9 9 9 9 9 9 
10 10 10 10 10 10 10 10 10 
11 11 11 11 11 11 11 11 11 11 
12 12 12 12 12 12 12 12 12 12 12 
13 13 13 13 13 13 13 13 13 13 13 13 
14 14 14 14 14 14 14 14 14 14 14 14 14 
15 15 15 15 15 15 15 15 15 15 15 15 15 15 
16 ...

result: