Submission #838453

#TimeUsernameProblemLanguageResultExecution timeMemory
838453Charizard2021Hiperkocka (COCI21_hiperkocka)C++17
110 / 110
50 ms8716 KiB
#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 (stderr)

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++){
      |                    ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...