Test instructions
There were n teams, and all the teams were going to play it again, and one of them did not give the result of the match.
Ideas
Obviously we can find out which two teams are not given from these pairs.
Then is to determine the outcome of the two teams, DFS to determine whether one of the map to the other can be reached.
Code
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <list>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace STD;#define LL Long Long#define LOWBIT (x) ((x) & ( -X))#define Lson L, Mid, RT << 1#define Rson Mid + 1, R, RT << 1|1#define MP (A, B) Make_pair (A, b)Const intINF =0x3f3f3f3f;Const intMOD =1000000007;Const intMAXN =1e5+Ten;Const DoubleEPS =1e-8;Const DoublePI =ACOs(-1.0);typedefpair<int,int> PII;intnum[ -];intvis[ -];intnum2; vector<int>g[ -];intDfsintu) {Vis[u] =1;if(U = = num2)return 1; for(inti =0; I < g[u].size (); i++) {if(Vis[g[u][i]] = =1)Continue;if(Dfs (G[u][i]))return 1; }return 0;}intMain () {//freopen ("In.txt", "R", stdin); //freopen ("OUT.txt", "w", stdout); intN, u, v;Cin>> N; for(inti =0; I < n * (N-1) /2-1; i++) {Cin>> u >> v; num[u]++, num[v]++; G[u].push_back (v); }intNUM1 =0; num2 =0; for(inti =1; I <= -; i++)if(Num[i] = = N-2) {if(!num1) num1 = i;Elsenum2 = i; }if(Dfs (NUM1))printf("%d%d\n", NUM1, num2);Else printf("%d%d\n", num2, NUM1);return 0;}
Codeforces 27b-tournament (DFS)