Submission #1165734

#TimeUsernameProblemLanguageResultExecution timeMemory
1165734tamyteCutting a rectangle (LMIO18_staciakampis)C++20
25 / 100
1093 ms2372 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<ll> a(n), b(n); for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; } vector<int> id(n); iota(begin(id), end(id), 0); set<ll> p; do { ll x = a[id[0]]; ll y = b[id[0]]; bool ok = true; for (int i = 1; ok && i < n; ++i) { int j = id[i]; if (x == a[j]) { y += b[j]; } else if (x == b[j]) { y += a[j]; } else if (y == a[j]) { x += b[j]; } else if (y == b[j]) { x += a[j]; } else { ok = false; } } if (ok) { p.insert(min(x, y)); } } while (next_permutation(begin(id), end(id))); cout << p.size() << endl; for (auto& u : p) { cout << u << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...