ICPC Greater New York Region 2020 (模拟)

测评地址

题意:

i c p c icpc icpc比赛的队伍排名。题数高的在前,相同题数用时少的在前,相同题数用时相同的比较 a c ac ac最后一题的时间、倒数第二题的时间……如果比较完后还是相同,两者排名相同。
输出前 n k nk nk名的信息。

思路:

存一个结构体里模拟即可,注意不足 n k nk nk的情况

代码:

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include<iostream>
#include<cstdio>
#include<string>
#include<ctime>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<cassert>
#include<bitset>
#include<list>
#include<unordered_map>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll>PLL;
typedef pair<int, int>PII;
typedef pair<double, double>PDD;
#define I_int ll
inline ll read(){ll x = 0, f = 1;char ch = getchar();while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}return x * f;}

inline void write(ll x){if (x < 0) x = ~x + 1, putchar('-');if (x > 9) write(x / 10);putchar(x % 10 + '0');}

#define read read()
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define multiCase int T;cin>>T;for(int t=1;t<=T;t++)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repp(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define perr(i,a,b) for(int i=(a);i>(b);i--)

ll ksm(ll a, ll b,ll mod){ll res = 1;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int maxn=2e5+100,inf=0x3f3f3f3f;

struct node{
	int id,cnt,time;
	int cost[25];
	int sub[25];
}a[110];

bool vis[110][25];
int wa[110][25];

int main(){
#ifdef LOCAL
    freopen("in.in","r",stdin);
    freopen("out.out","w",stdout);
#endif
	int nt=read,np=read,ns=read,nk=read;
	rep(i,1,nt) a[i].id=i;
	while(ns--){
		int teamid=read,pid=read,subtime=read,op=read;
		if(vis[teamid][pid]){
			continue;
		}
		else{
			if(op==1){
				a[teamid].cnt++;
				int t=a[teamid].cnt;
				a[teamid].sub[t]=subtime;
				a[teamid].cost[t]= wa[teamid][pid]*20+subtime;//a[teamid].sub[t]-a[teamid].sub[t-1];
				vis[teamid][pid]=1;
				a[teamid].time+=wa[teamid][pid]*20+subtime;
			}
			else wa[teamid][pid]++;
		}
	}
	for(int i=1;i<=nt;i++){
		for(int j=i+1;j<=nt;j++){
			if(a[i].cnt<a[j].cnt) swap(a[i],a[j]);
			else if(a[i].cnt==a[j].cnt){
				if(a[i].time>a[j].time) swap(a[i],a[j]);
				else if(a[i].time==a[j].time){
					bool flag=1;
					for(int k=a[i].cnt;k>=1;k--){
						if(a[i].cost[k]<a[j].cost[k]){
							flag=0;break;
						}
						
						else if(a[i].cost[k]>a[j].cost[k]){
							flag=0;swap(a[i],a[j]);break;
						}
					}
					if(flag){
						if(a[i].id>a[j].id) swap(a[i],a[j]);
					}
				}
			}
		}
	}
	/*for(int j=1;j<=nt;j++){
		cout<<a[j].id<<" "<<a[j].cnt<<" "<<a[j].time<<endl;
		for(int i=1;i<=a[j].cnt;i++)
			cout<<a[j].cost[i]<<" ";
		puts("");
	}*/
		
	int now=1,cnt=0;
	while(cnt<=nk){
		int tmp=1;
		for(int i=now+1;i<=nt;i++){
			if(a[i].cnt==a[now].cnt&&a[i].time==a[now].time){
				bool flag=1;
				for(int j=a[i].cnt;j;j--)
					if(a[i].cost[j]!=a[now].cost[j]){
						flag=0;break;
					}
				if(!flag) break;
				tmp++;
			}
		}
		for(int i=1,j=now;i<=tmp;i++,j++){
			//cout<<cnt+1<<" "<<a[j].id<<" "<<a[j].cnt<<" "<<a[j].time<<endl;
			printf("%-4d%-4d%3d%5d\n",cnt+1,a[j].id,a[j].cnt,a[j].time);
		//	printf("%-4d%-4d%3d%5d\n",cnt+1,a[j].id,a[j],cnt,a[j].time);
		}
		now=now+tmp;
		cnt+=tmp;
	//	cout<<cnt<<endl;
		if(cnt>=nk) break;
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

豆沙睡不醒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值