제출 #429496

#제출 시각아이디문제언어결과실행 시간메모리
429496Trickster사육제 (CEOI14_carnival)C++14
20 / 100
150 ms384 KiB
//Suleyman Atayew #include <algorithm> #include <iostream> #include <string.h> #include <stdio.h> #include <vector> #include <bitset> #include <queue> #include <cmath> #include <map> #include <set> #define N 160 #define ff first #define ss second #define pb push_back #define ll long long #define mod 1000000007 #define pii pair <int, int> #define sz(a) (int)(a.size()) ll bigmod(ll a, ll b) { if(b==0)return 1; ll ret = bigmod(a, b/2); return ret * ret % mod * (b%2 ? a : 1) % mod; } using namespace std; int n; int v[N][N], P[N]; int ata(int x) { if(x == P[x]) return x; return P[x] = ata(P[x]); } void uni(int a, int b) { a = ata(a); b = ata(b); if(a == b) return; P[b] = a; } int main() { cin >> n; for(int i = 1; i <= n; i++) P[i] = i; for(int i = 1; i <= n; i++) for(int h = 1; h <= n; h++) v[i][h] = 2; for(int i = 1; i <= n; i++) { for(int h = 1; h <= n; h++) { if(i == h || v[i][h] != 2) continue; int x; cout << "2 " << i << " " << h << "\n"; cout.flush(); cin >> x; if(x == 1) v[i][h] = v[h][i] = 1; else v[i][h] = v[h][i] = 0; } for(int h = 1; h <= n; h++) { if(v[i][h] != 1) continue; for(int j = 1; j <= n; j++) { if(v[i][j] == 0) v[h][j] = v[j][h] = 0; if(v[i][j] == 1) v[h][j] = v[j][h] = 1; } } } for(int i = 1; i <= n; i++) for(int h = 1; h <= n; h++) if(i != h && v[i][h] == 1) uni(i, h); cout << "0 "; int sz = 0; map <int, int> M; for(int i = 1; i <= n; i++) { if(M[ata(i)] == 0) M[ata(i)] = ++sz; cout << M[ata(i)] << " "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...