답안 #838453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
838453 2023-08-27T02:45:54 Z Charizard2021 Hiperkocka (COCI21_hiperkocka) C++17
110 / 110
50 ms 8716 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> adj[1 + n];
    for(int i =0 ; i < n; i++){
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<int> topo(1 + n, -1);
    vector<int> parent(1 + n);
    int timer = 0;
    queue<int> q;
    q.push(0);
    topo[0] = timer;
    timer++;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int v : adj[u]){
            if(topo[v] == -1){
                topo[v] = timer;
                timer++;
                parent[topo[v]] = topo[u];
                q.push(v);
            }
        }
    }
    vector<vector<int> > ans;
    vector<int> cur;
    cur.push_back(0);
    cur.push_back(1);
    ans.push_back(cur);
    for(int i = 1; i < n; i++){
        int curVal = ans.size();
        for(int j = 0; j < curVal; j++){
            ans.push_back(ans[j]);
            for(int k = 0; k < ans[(int)ans.size() - 1].size(); k++){
                ans[(int)ans.size() - 1][k] ^= 1 ^ (1 << i);
            }
        }
        for(int j = 0; j < ans.size(); j++){
            ans[j].push_back(ans[j][parent[i + 1]] ^ (1 << i));
        }
    }
    cout << ans.size() << "\n";
    for(int i = 0; i < ans.size(); i++){
        for(int j = 0; j <= n; j++){
            cout << ans[i][topo[j]] << " ";
        }
        cout << "\n";
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:41:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             for(int k = 0; k < ans[(int)ans.size() - 1].size(); k++){
      |                            ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:45:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(int j = 0; j < ans.size(); j++){
      |                        ~~^~~~~~~~~~~~
Main.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i = 0; i < ans.size(); i++){
      |                    ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 49 ms 8592 KB Output is correct
10 Correct 5 ms 1108 KB Output is correct
11 Correct 11 ms 2004 KB Output is correct
12 Correct 49 ms 8604 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 50 ms 8664 KB Output is correct
15 Correct 29 ms 4108 KB Output is correct
16 Correct 11 ms 2060 KB Output is correct
17 Correct 50 ms 8624 KB Output is correct
18 Correct 49 ms 8576 KB Output is correct
19 Correct 48 ms 8588 KB Output is correct
20 Correct 48 ms 8620 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 49 ms 8668 KB Output is correct
23 Correct 48 ms 8648 KB Output is correct
24 Correct 49 ms 8636 KB Output is correct
25 Correct 50 ms 8716 KB Output is correct
26 Correct 24 ms 4152 KB Output is correct