2021牛客多校2 D Er Ba Game

Posted 你可以当我没名字

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2021牛客多校2 D Er Ba Game相关的知识,希望对你有一定的参考价值。

链接:https://ac.nowcoder.com/acm/contest/11253/D
来源:牛客网

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld

题目描述

Er Ba Game is a popular card game in China’s Province Zhejiang.

In this problem, the game involves two players and 36 cards - 2,3,⋯ ,102,3,\\cdots, 102,3,⋯,10, each with four.

In the game each player takes 2 cards (a1,b1)(a_1,b_1)(a1​,b1​) , (a2,b2)(a_2,b_2)(a2​,b2​) .Player i{i}i gets (ai,bi)(a_i,b_i)(ai​,bi​) . Suppose a1≤b1,a2≤b2a_1\\leq b_1,a_2\\leq b_2a1​≤b1​,a2​≤b2​, and we determine the winner as follow:

  1. ​ (2,8){(2,8)}(2,8) is the biggest pair.
  2. ​ If neither is (2,8){(2,8)}(2,8), a pair with a=b{a=b}a=b is greater than a pair without.
  3. ​ If a1=b1a_1=b_1a1=b1 and a2=b2a_2=b_2a2=b2, then compare a1,a2a_1,a_2a1,a2.The bigger one wins.
  4. ​ If a1≠b1,a2≠b2a_1\\ne b_1,a_2\\ne b_2a1\\=b1,a2\\=b2, compare (a1+b1) mod 10,(a2+b2) mod 10(a_1+b_1)\\ \\text{mod}\\ 10,(a_2+b_2)\\ \\text{mod}\\ 10(a1+b1) mod 10,(a2+b2) mod 10.The bigger one wins.
  5. ​ If a1≠b1,a2≠b2a_1\\ne b_1,a_2\\ne b_2a1\\=b1,a2\\=b2 and (a1+b1) mod 10=(a2+b2) mod 10(a_1+b_1)\\ \\text{mod}\\ 10=(a_2+b_2)\\ \\text{mod}\\ 10(a1+b1) mod 10=(a2+b2) mod 10,compare b1,b2b_1,b_2b1,b2.The bigger one wins.

If a1≤b1,a2≤b2a_1\\leq b_1,a_2\\leq b_2a1≤b1,a2≤b2 does not hold, we can exchange a1a_1a1 and b1b_1b1 or exchange a2a_2a2 and b2b_2b2 until the formula holds.

You’re told a1,b1,a2,b2a_1,b_1,a_2,b_2a1,b1,a2,b2, and you should tell who’s gonna win the game.

输入描述:

The first line contains an integer T{T}T — number of game cases.
Then T{T}T lines, each contains four integers a1,b1,a2,b2a_1,b_1, a_2,b_2a1,b1,a2,b2, denoting the cards of each player.

输出描述:

Output T{T}T lines.


If player 1 wins, output "first" (without quote).


If player 2 wins, output "second" (without quote).


Otherwise, output "tie" (without quote).

示例1

输入

[复制](javascript:void(0)😉

5
2 8 4 6
6 6 6 7
4 5 5 5
6 3 9 10
7 2 2 7

输出

[复制](javascript:void(0)😉

first
first
second
second
tie

说明

The answers to the first four sets of data are obtained through the first, second, second, and fifth rules respectively.

备注:

It's guaranteed that T≤100,2≤a1,b1,a2,b2≤10T\\leq 100,2\\leq a_1,b_1,a_2,b_2\\leq 10T≤100,2≤a1,b1,a2,b2≤10.

It's not guaranteed that a1≤b1,a2≤b2a_1\\leq b_1,a_2\\leq b_2a1≤b1,a2≤b2.

思路与代码

简单模拟
看懂题目后按照题目意思写就行

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <vector>
#include <limits.h>
#include <assert.h>
#include <functional>
#include <numeric>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb          push_back
#define ppb         pop_back
#define lbnd        lower_bound
#define ubnd        upper_bound
#define endl        '\\n'
#define mll         map<ll,ll>
#define msl         map<string,ll>
#define mls         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x)  for(auto& a : x)
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define vll         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define DEBUG       cerr<<"/n>>>I'm Here<<</n"<<endl;
#define display(x)  trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ini(a)      memset(a,0,sizeof(a))
#define ini2(a,b)   memset(a,b,sizeof(a))
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define sc          ll T;cin>>T;for(ll Q=1;Q<=T;Q++)
#define lowbit(x)   x&(-x)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DBG(x) \\
    (void)(cout << "L" << __LINE__ \\
    << ": " << #x << " = " << (x) << '\\n')
#define TIE \\
    cin.tie(0);cout.tie(0);\\
    ios::sync_with_stdio(false);

//using namespace __gnu_pbds;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 2000;
const int N = 500009;


void solve(){
	int a1,b1,a2,b2,ans = 0;
	cin>>a1>>b1>>a2>>b2;
	if(a1>b1)a1^=b1^=a1^=b1;
	if(a2>b2)a2^=b2^=a2^=b2;
	if(a1==a2&&b1==b2){//相等 
		ans = 0;
	}else if(a1==2&&b1==8){
		ans = 1;
	}else if(a2==2&&b2==8){
		ans = 2;
	}else if(a1==b1&&a2==b2){
		if(a1>a2){
			ans = 1;
		}else if(a1<a2){
			ans = 2;
		}else{
			ans = 0;
		}
	}else if(a1==b1){
		ans = 1;
	}else if(a2==b2){
		ans = 2;
	}else if(a1!=b1&&a2!=b2){
		int q1 = (a1+b1)%10;
		int q2 = (a2+b2)%10;
		if(q1>q2)ans = 1;
		else if(q1<q2)ans = 2;
		else{
			if(b1>b2)ans = 1;

			else if(b1<b2)ans = 2;
			else ans = 0;
		}
	}else{
		ans = 0;
	}
	if(ans==0){
		cout<<"tie"<<endl;
	}else if(ans==1){
		cout<<"first"<<endl;
	}else{
		cout<<"second"<<endl;
	}
}

int main()
{
//    #ifndef ONLINE_JUDGE
//    freopen ("input.txt","r",stdin);
//    #else
//    #endif
//	solve();
    sc{solve();}
//    int p;
//    while(cin>>p){
//    	while(p--){
//    		solve();
//		}
//	}
//    sc{cout<<"Case "<<Q<<":"<<endl;solve();}
}







以上是关于2021牛客多校2 D Er Ba Game的主要内容,如果未能解决你的问题,请参考以下文章

2021牛客多校8 D OR

2021牛客多校8 D.OR(位运算)

2021牛客多校7 Fxay loves trees

2021牛客多校1 D Determine the Photo Position

2021牛客多校2 - Girlfriend(球体积交)

2021牛客多校2 C Draw Grids