QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#324363#8230. Submissionsucup-team918#WA 9ms73284kbC++174.2kb2024-02-10 17:59:592024-02-10 18:00:00

Judging History

你现在查看的是最新测评结果

  • [2024-05-20 23:50:57]
  • hack成功,自动添加数据
  • (/hack/623)
  • [2024-05-20 23:48:44]
  • hack成功,自动添加数据
  • (/hack/622)
  • [2024-02-10 18:00:00]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:73284kb
  • [2024-02-10 17:59:59]
  • 提交

answer

/* Code by pp_orange */
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define m_p(a,b) make_pair(a,b)
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 0x7FFFFFFF
#define inff 9223372036854775807
#define rep(i,l,r) for(int i=l;i<r;++i)
#define repp(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r-1;i>=l;--i)
#define pper(i,r,l) for(int i=r;i>=l;--i)
#define pii pair<int,int>
#define fi first
#define se second
#define p_q priority_queue
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ls(x) ((x)<<1)
#define rs(x) ((x)<<1|1)
#define lb(x) ((x)&-(x))
#define lg(x) (31^__builtin_clz(x))
#define vi vector<int>
#define vii vector<pii >
const int mod = 998244353;
//#define int ll
const int intsz = sizeof(int);
using namespace std;
inline int rd(){
	int x(0),f(1);char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
	while (isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return x*f;
}
inline void out(int X){
	if(X<0) {X=~(X-1); putchar('-');}
	if(X>9) out(X/10);
	putchar(X%10+'0');
}
ll pw(ll x,int d){
	ll t = 1;
	for(;d;d>>=1,x=x*x%mod)if(d&1)t = t*x%mod;
	return t;
}
#define MAX 100005
map<string,int> mp;
string nmstr[MAX];
int namec;
vector<pii> sub[MAX][26];
bool pas[MAX][26];
int badsub[MAX][26];
pair<pii,int> sa[MAX];
int vis[MAX];
bool cmp(pair<pii,int> x,pair<pii,int> y){
	if(x.fi.fi!=y.fi.fi)return x.fi.fi>y.fi.fi;
	return x.fi.se<y.fi.se;
}
bool cmp2(pii x,pii y){
	if(x.fi!=y.fi)return x.fi>y.fi;
	return x.se<=y.se;
}
void solve(){
	mp.clear();
	namec = 0;
	int n = rd();
	repp(i,1,n){
		rep(j,0,26){
			sub[i][j].clear();
			pas[i][j] = 0;
			badsub[i][j] = 0;
		}
	}
	repp(i,1,n)vis[i] = 0;
	repp(i,1,n){
		string c,stu;
		int t;char p;
		cin>>c>>p>>t>>stu;
		if(mp.count(c)==0){
			mp[c] = ++namec;
		}
		int idx = mp[c];
		nmstr[idx] = c;
		int pidx = p-'A';
		bool flag = stu[0]=='a'?1:0;
		sub[idx][pidx].pb({flag,t});
	}
	int lim = min(35,(n+9)/10);
	repp(i,1,namec){
		pii rlt = {0,0};
		rep(j,0,26){
			for(auto itm:sub[i][j]){
				if(itm.fi){
					rlt.fi++,rlt.se+=itm.se+badsub[i][j]*20;
					pas[i][j] = 1;
					break;
				}
				badsub[i][j]++;				
			}
		}
		sa[i] = {rlt,i};
	}
	sort(sa+1,sa+1+namec,cmp);
	int lst = 1;
	int cnt = 1;
	repp(i,2,namec){
		if(sa[i].fi==sa[i-1].fi){
			lst = i;
			cnt++;
		}else if(i<=lim){
			lst = i;
			cnt = 1;
		}
	}
	// cout<<"lim = "<<lim<<endl;
	// cout<<"namec = "<<namec<<' '<<lst<<endl;
	// repp(i,1,namec){
	// 	cout<<sa[i].se<<" : "<<sa[i].fi.fi<<' '<<sa[i].fi.se<<endl;
	// }cout<<endl;
	repp(i,1,lst)vis[sa[i].se] = 1;
	if(lst==namec){
		// cout<<n<<endl;
		// repp(i,1,n){
		// 	cout<<nmstr[i]<<' ';
		// }cout<<endl;
		return ;
	}
	int cnt2 = 1;
	repp(i,lst+2,namec){
		if(sa[i].fi==sa[i-1].fi){
			cnt2++;
		}else{
			break;
		}
	}
	// cout<<"cnt2 = "<<cnt2<<endl;
	if(lst==lim){
		bool ok = 0;
		repp(i,1,lim){
			int mn = 0,nw = 0;
			rep(j,0,26){
				int cc = 0;
				for(auto [f,t] : sub[i][j]){
					cc += f;
				}
				if(cc > 1){

				}
			}
			int lstp,lstt;
			tie(lstp,lstt) = sa[i].fi;
			if(cmp2(sa[lst+1].fi,m_p(lstp,lstt))){
				ok = 1;
				break;
			}
		}
		if(ok){
			repp(i,lst+1,lst+cnt2){
				vis[sa[i].se] = 1;
			}
		}
	}
	const int B = 100000000;
	repp(i,1,namec){
		int num = sa[i].se;
		if(vis[num]==1)continue;
		int mn = inf;
		int nw = inf;
		rep(j,0,26){
			if(pas[num][j]){
				mn = min(mn,-badsub[num][j]*20);
			}else{
				if(badsub[num][j]){
					nw = min(nw,sub[num][j][0].se);
				}
			}
		}
		int lstp,lstt;
		tie(lstp,lstt) = sa[i].fi;
		if(nw<B){
			lstp++;
			lstt += nw;
		}else if(mn<B){
			lstt += mn;
		}
		// cout<<"i = "<<i<<endl;
		// cout<<lstp<<','<<lstt<<" : "<<cmp2(m_p(lstp,lstt),sa[lst].fi)<<' '<<sa[lst].fi.fi<<endl;
		if(cmp2(m_p(lstp,lstt),sa[lst].fi)){
			vis[num] = 1;
		}
	}
	int anscnt = 0;
	repp(i,1,n){
		anscnt += vis[i];
	}
	cout<<anscnt<<endl;
	repp(i,1,n){
		if(vis[i]){
			cout<<nmstr[i]<<' ';
		}
	}cout<<endl;
	return ;
}
signed main(){
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	int T = rd();
	while(T--){
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 69940kb

input:

2
5
TSxingxing10 G 0 rejected
TSxingxing10 B 83 accepted
aoliaoligeiliao J 98 accepted
TS1 J 118 accepted
TS1 B 263 accepted
12
AllWayTheNorth A 0 rejected
YaoYaoLingXian Y 10 accepted
XuejunXinyoudui1 X 200 rejected
XuejunXinyoudui1 X 200 accepted
LetItRot L 215 accepted
AllWayTheNorth W 250 accept...

output:

2
TSxingxing10 TS1 
4
AllWayTheNorth XuejunXinyoudui1 LetItRot ImYourFan 

result:

ok 2 test cases ok. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 9ms
memory: 73284kb

input:

2
2
jiangly_fan A 1 accepted
jiangly B 23 accepted
3
conqueror_of_tourist A 1 accepted
conqueror_of_tourist A 2 accepted
tourist B 23 accepted

output:

1
jiangly_fan 
1
conqueror_of_tourist 

result:

wrong answer the numbers are different in the case 1. (test case 1)