Submission #1103927

#TimeUsernameProblemLanguageResultExecution timeMemory
1103927PacybwoahTable Tennis (JOI24_tabletennis)C++17
9 / 100
314 ms12956 KiB
#include<iostream>
#include<vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    int n, m;
    cin >> t;
    while(t--){
        cin >> n >> m;
        if(m <= n - 2){
            cout << "Yes\n";
            for(int i = 2; i < n; i++) {
                for(int j = 1; j < i; j++) cout << "1";
                cout << "\n";
            }
            for(int j = 1; j < n; j++){
                if(j + m == n - 1) cout << "0";
                else cout << "1"; 
            }
            cout << "\n";
            continue;
        }
        else if(n <= 7){
            int tot = n * (n - 1) / 2;
            int ans = -1, cnt;
            vector<vector<int>> edges(n + 1, vector<int>(n + 1));
            for(int i = 0; i < (1 << tot); i++){
                cnt = 0;
                for(int j = 2; j <= n; j++){
                    for(int k = 1; k < j; k++){
                        if((1 << cnt) & i){
                            edges[k][j] = 1;
                        }
                        else edges[k][j] = 0;
                        cnt++;
                    }
                }
                cnt = 0;
                for(int j = 1; j <= n; j++){
                    for(int k = j + 1; k <= n; k++){
                        for(int l = k + 1; l <= n; l++){
                            if(edges[j][k] == edges[k][l] && edges[j][k] != edges[j][l]) cnt++;
                        }
                    }
                }
                if(cnt == m){
                    ans = i;
                    break;
                }
            }
            if(ans == -1) cout << "No\n";
            else{
                cout << "Yes\n";
                cnt = 0;
                for(int i = 2; i <= n; i++){
                    for(int j = 1; j < i; j++){
                        if(ans & (1 << cnt)) cout << "1";
                        else cout << "0";
                        cnt++;
                    }
                    cout << "\n";
                }
            }
            continue;
        }
    }
}
// g++ -std=c++17 -Wall -Wextra -Wshadow -fsanitize=undefined -fsanitize=address -o run pingpong.cpp
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...