답안 #1053304

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053304 2024-08-11T10:23:51 Z Ludissey Make them Meet (EGOI24_makethemmeet) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define int long long
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()

using namespace std;
int N,M,Q;
signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N >> M;
    vector<pair<int,int>> ed(M);
    for (int i = 0; i < M; i++)
    {
        cin >> ed[i].first >> ed[i].second;
        if(ed[i].first>ed[i].second) swap(ed[i].first,ed[i].second);
    }
    sort(all(ed));
    bool star=true;
    bool complete=(M==(N*(N-1))/2);
    bool path=0;
    for (int i = 0; i < M; i++)
    {
        if(ed[i].first!=i||ed[i].second!=i+1) path=false;
        if(ed[i].first!=0) star=false;
    }
    if(star){
        cout << (2*M)+2 << "\n";
        for (int i = 0; i < N; i++) cout << 0 << " ";
        cout << "\n";        
        for (int i = 0; i < N; i++) cout << 0 << " ";
        cout << "\n";       
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++)
            {
                if(j==ed[i].first||j==ed[i].second) cout << 0 << " ";
                else cout << j+1 << " ";
            }
            cout << "\n";
            for (int j = 0; j < N; j++)
            {
                if(j==ed[i].first||j==ed[i].second) cout << 0 << " ";
                else cout << j+1 << " ";
            }
            cout << "\n";
        }
    } if(complete){
        cout << (2*M) << "\n";
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++)
            {
                if(j==ed[i].first||j==ed[i].second) cout << 0 << " ";
                else cout << 1 << " ";
            }
            cout << "\n";
            for (int j = 0; j < N; j++)
            {
                if(j==ed[i].first||j==ed[i].second) cout << 0 << " ";
                else cout << 1 << " ";
            }
            cout << "\n";
        }
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:20:10: warning: variable 'path' set but not used [-Wunused-but-set-variable]
   20 |     bool path=0;
      |          ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Trailing output, expected EOF
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Trailing output, expected EOF
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Trailing output, expected EOF
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Trailing output, expected EOF
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Trailing output, expected EOF
2 Halted 0 ms 0 KB -