# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
861145 | JoanaPA | Carnival (CEOI14_carnival) | C++14 | 73 ms | 344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<vector>
#include<map>
#include<unordered_set>
#include<set>
#include<algorithm>
using namespace std;
vector<int> resolver(int N) {
// Hacemos consultas para ver que parejas coinciden
vector<vector<int>> mismoDisfraz = vector<vector<int>>(N, vector<int>(N, 0));
int respuesta;
for (int i = 0; i < N; i++) {
for (int j = i+1; j < N; j++) {
cout << "2 " << i+1 << ' ' << j+1 << '\n';
cin >> respuesta;
mismoDisfraz[i][j] = mismoDisfraz[j][i] = 2-respuesta;
}
}
// Sabiendo las parejas, construimos la lista de disfraces
vector<int> disfraces(N, 0);
int disfracesDescubiertos = 0;
for (int j = 0; j < N; j++) {
// Vemos si coincide con otro nodo con disfraz asignado => le asignamos el mismo
for (int i = 0; i < j; i++) {
if (mismoDisfraz[i][j]) {
disfraces[j] = disfraces[i];
}
}
if (disfraces[j] == 0) {
// No coincide => nuevo disfraz
disfracesDescubiertos++;
disfraces[j] = disfracesDescubiertos;
}
}
return disfraces;
}
int main() {
int N, C;
cin >> N;
vector<int> solucion = resolver(N);
cout << 0;
for (int i = 0; i < N; ++i) {
cout << " " << solucion[i];
}
cout << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |