Submission #331769

#TimeUsernameProblemLanguageResultExecution timeMemory
331769thecodingwizardIzlet (COI19_izlet)C++11
18 / 100
591 ms53740 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ii pair<int, int> #define f first #define s second #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define F0R(i, n) for (int i = 0; i < n; i++) #define FOR(i, a, b) for (int i = a; i < b; i++) #define inf 1000000010 #define maxn 3000 int n; int input[maxn][maxn]; vector<int> nodes; // stores nodes remaining after 1's are compressed map<int, vector<int>> nodesInOneComponent; void compressOnes() { vector<bool> done(n, 0); F0R(i, n) { if (done[i]) continue; nodes.pb(i); done[i] = true; F0R(j, n) { if (input[i][j] == 1 && j != i) { nodesInOneComponent[i].pb(j); done[j] = true; } } } } void findTwos() { } int assignedColor[maxn]; vector<ii> outputEdges; void buildTree() { assignedColor[nodes[0]] = 1; FOR(i, 1, nodes.size()) { outputEdges.emplace_back(nodes[0], nodes[i]); assignedColor[nodes[i]] = 2; } } void decompressOnes() { for (int x : nodes) { for (int y : nodesInOneComponent[x]) { outputEdges.pb(mp(x, y)); assignedColor[y] = assignedColor[x]; } } } int main() { cin.tie(0)->sync_with_stdio(0); int subtask; cin >> subtask; assert(subtask == 1); cin >> n; F0R(i, n) { F0R(j, n) { cin >> input[i][j]; } } compressOnes(); findTwos(); buildTree(); decompressOnes(); F0R(i, n) cout << assignedColor[i] << " "; cout << endl; for (auto x : outputEdges) cout << x.f+1 << " " << x.s+1 << endl; return 0; }

Compilation message (stderr)

izlet.cpp: In function 'void buildTree()':
izlet.cpp:13:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 | #define FOR(i, a, b) for (int i = a; i < b; i++)
......
   46 |     FOR(i, 1, nodes.size()) {
      |         ~~~~~~~~~~~~~~~~~~              
izlet.cpp:46:5: note: in expansion of macro 'FOR'
   46 |     FOR(i, 1, nodes.size()) {
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...