Тест:
3
1 2
3 2
1 3
3 1
2 1
2 3
Не могу понять можно ли ставить в одно поле одни и те же команды но под разными цветами
Вот мой код
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define sz(x) (int)x.size()
#define speed ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
const ll INF = INT_MAX;
map<pii, int> used;
int main() {
speed;
int n;
cin>>n;
n*=2;
map<int, vector<int>> r;
map<int, vector<int>> w;
map<pii, int> pos;
set<int> ans;
for(ll i = 0; i<n; i++){
ll u, b;
cin>>u>>b;
r[u].pb(b);
w[b].pb(u);
pos[{u, b}] = i + 1;
used[{u, b}] = 0;
}
if(n/2 == 2){
cout<<"YES\n";
cout<<pos[{1LL, 2LL}]<<" "<<pos[{2LL, 1LL}];
return 0;
}
for(int i = 1; i<=n/2; i++){
int j = 0;
for(; j<2; j++){
if(!used[{i, r[i][j]}])break;
}
if(j == 2){
cout<<"NO";
return 0;
}
ans.insert(pos[{i, r[i][j]}]);
used[{i, r[i][j]}] = 1;
used[{r[i][j], i}] = 1;
used[{w[r[i][j]][0], r[i][j]}] = 1;
used[{w[r[i][j]][1], r[i][j]}] = 1;
}
cout<<"YES\n";
for(auto i:ans)cout<<i<<"\n";
return 0;
}