QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#414793 | #8230. Submissions | ucup-team052 | RE | 163ms | 7800kb | C++23 | 3.5kb | 2024-05-19 18:44:38 | 2024-05-19 18:44:38 |
Judging History
answer
#include<bits/stdc++.h>
#define D(...) fprintf(stderr,__VA_ARGS__)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
using LL=long long;
const int N=100005;
int T,m;
map<string,int>ID;
int idx;
string aID[N];
int getID(string s){
if(ID.count(s))return ID[s];
return aID[++idx]=s,ID[s]=idx;
}
struct node{
int c;
char p;
int t,s;
}A[N];
int cmp(const pair<int,int>&lhs,const pair<int,int>&rhs){ // lhs better
if(lhs.first!=rhs.first){
return lhs.first>rhs.first;
}else{
return lhs.second<rhs.second;
}
}
pair<int,int>Max(const pair<int,int>&lhs,const pair<int,int>&rhs){
return cmp(lhs,rhs)?lhs:rhs;
}
pair<int,int>Min(const pair<int,int>&lhs,const pair<int,int>&rhs){
return cmp(lhs,rhs)?rhs:lhs;
}
pair<int,int>operator+(const pair<int,int>&lhs,const pair<int,int>&rhs){
return make_pair(lhs.first+rhs.first,lhs.second+rhs.second);
}
pair<int,int>operator-(const pair<int,int>&lhs,const pair<int,int>&rhs){
return make_pair(lhs.first-rhs.first,lhs.second-rhs.second);
}
int main(){
#ifdef xay5421
freopen("a.in","r",stdin);
#endif
cin>>T;
while(T--){
ID.clear();
idx=0;
cin>>m;
rep(i,1,m){
static string s1,s2;
cin>>s1>>A[i].p>>A[i].t>>s2;
A[i].c=getID(s1);
A[i].s=(s2[0]=='a');
}
vector<array<vector<pair<int,int> >,26> >v(idx+1);
rep(i,1,m){
v[A[i].c][A[i].p-'A'].emplace_back(A[i].t,A[i].s);
}
vector<pair<int,int> >w(idx+1),mxw(idx+1),mnw(idx+1);
vector<int>maxT(idx+1,-1);
vector<int>cnt(idx+1);
int n0=0;
rep(c,1,idx){
rep(p,0,25){
int flag=0,pd=0;
int T=0;
pair<int,int>now={0,0},mx={0,0},mn={1e9,1e9};
for(auto&x:v[c][p]){
if(x.second){
if(!flag){
flag=1;
now.first=1;
now.second=x.first+T;
}else if(!pd){
pd=1;
mn=Min(mn,{1,x.first+T});
}
}else{
if(!flag){
mx=Max(mx,{1,x.first+T});
}
maxT[c]=max(maxT[c],x.first+T);
T+=20;
}
}
if(!pd){
mn=Min(mn,{0,0});
}
w[c]=w[c]+now;
mxw[c]=Max(mxw[c],mx-now);
mnw[c]=Min(mnw[c],mn-now);
cnt[c]+=flag;
}
n0+=cnt[c]>=1;
mxw[c]=mxw[c]+w[c];
mnw[c]=mnw[c]+w[c];
}
vector<int>ord(idx);
rep(i,0,idx-1)ord[i]=i+1;
sort(ord.begin(),ord.end(),[&](int lhs,int rhs){return cmp(w[lhs],w[rhs]);});
vector<int>ans;
vector<int>tag(idx+1);
int pos=-1;
rep(i,0,SZ(ord)-1){
{
int n1=n0;
n1-=w[ord[i]].first>=1;
n1+=mnw[ord[i]].first>=1;
int C=min((n1+9)/10,35);
pos=max(pos,C-1);
if(C>=1&&i<C&&!cmp(mnw[ord[i]],w[ord[C]])){
pos=max(pos,C);
}
}
{
int n1=n0;
n1-=w[ord[i]].first>=1;
n1+=mxw[ord[i]].first>=1;
int C=min((n1+9)/10,35);
if(C>=1&&!cmp(w[ord[C-1]],mxw[ord[i]])){
tag[ord[i]]=1;
}
}
if(cnt[ord[i]]==0){
if(maxT[ord[i]]!=-1){
int n1=n0+1;
int C=min((n1+9)/10,35);
if(C>=1&&!cmp(make_pair(1,maxT[ord[i]]),w[ord[C-1]])){
pos=max(pos,C-1);
}
}
}
int C=min((n0+9)/10,35);
if(i<C)tag[ord[i]]=1;
}
while(pos+1<SZ(ord)&&w[ord[pos]]==w[ord[pos+1]])++pos;
rep(i,0,SZ(ord)-1){
if(i<=pos||tag[ord[i]]){
ans.push_back(ord[i]);
}
}
printf("%d\n",SZ(ans));
rep(i,0,SZ(ans)-1)printf("%s%c",aID[ans[i]].c_str(),i==SZ(ans)-1?'\n':' ');
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7228kb
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 TS1 TSxingxing10 4 AllWayTheNorth XuejunXinyoudui1 LetItRot ImYourFan
result:
ok 2 test cases ok. (2 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 7244kb
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:
2 jiangly_fan jiangly 1 conqueror_of_tourist
result:
ok 2 test cases ok. (2 test cases)
Test #3:
score: 0
Accepted
time: 0ms
memory: 6912kb
input:
2 13 A A 1 accepted A X 1 accepted K K 1 rejected B B 2 accepted C C 2 accepted D D 2 accepted E E 2 accepted F F 2 accepted G G 2 accepted H H 2 accepted I I 2 accepted J J 2 accepted K K 2 rejected 12 A A 1 accepted A X 1 accepted B B 2 accepted C C 2 accepted D D 2 accepted E E 2 accepted F F 2 a...
output:
11 A B C D E F G H I J K 1 A
result:
ok 2 test cases ok. (2 test cases)
Test #4:
score: 0
Accepted
time: 1ms
memory: 6932kb
input:
2 11 A A 1 accepted B B 1 accepted C C 2 accepted D D 2 accepted E E 2 accepted F F 2 accepted G G 2 accepted H H 2 accepted I I 2 accepted J J 2 accepted K K 2 accepted 12 A A 1 accepted A X 1 accepted K K 1 rejected B B 2 accepted C C 2 accepted D D 2 accepted E E 2 accepted F F 2 accepted G G 2 a...
output:
2 A B 2 A K
result:
ok 2 test cases ok. (2 test cases)
Test #5:
score: 0
Accepted
time: 163ms
memory: 7800kb
input:
100000 1 M3JytWoaEXxkACy_mBAQ R 111 accepted 1 sQ O 151 accepted 1 JinbrcS58gNEE5yTSkT B 140 accepted 1 cklwBY V 243 accepted 1 v_o42YmvEKFwy Q 260 rejected 1 ftQVK8S_um22w K 265 accepted 1 _bQBeFeDpYQhvZcLf9l3 Z 147 accepted 1 KvDcEAIDN A 75 rejected 1 H3MUK6 A 101 rejected 1 gxYo_oCFn2J8aIben U 54...
output:
1 M3JytWoaEXxkACy_mBAQ 1 sQ 1 JinbrcS58gNEE5yTSkT 1 cklwBY 1 v_o42YmvEKFwy 1 ftQVK8S_um22w 1 _bQBeFeDpYQhvZcLf9l3 1 KvDcEAIDN 1 H3MUK6 1 gxYo_oCFn2J8aIben 1 _isnlUGK0ddI 1 BERcVjyCp 1 6In2do_50ylch 1 f0r3SXc6brMjT 1 7njYOapSwvogA 1 x 1 y1w3KvxylfxwprRBYw 1 aGedzS 1 iPo0GDhIF 1 4Vf5RXaTmySkFcXgHLOh 1...
result:
ok 100000 test cases ok. (100000 test cases)
Test #6:
score: -100
Runtime Error
input:
10000 42 Bzs0PiQMXGZ5rRZ_2D G 2 accepted 9XtB_VIfbRRL E 11 accepted FVJL M 13 rejected a S 19 accepted tsd Z 20 rejected MyCqVEg1ONjZ U 22 accepted 6SgZMn N 51 rejected Qua1Pti3vKhyQKDUm P 54 accepted i29 M 63 accepted zPqu D 68 rejected xx2yiu6x C 71 rejected fYuK1KNkuyO5HRCq L 76 rejected tXWpYVqj...
output:
4 Qua1Pti3vKhyQKDUm fYuK1KNkuyO5HRCq xiLm0TUOF3T tsd 2 t3 JP 2 fhYPGC8W82NwJTQL 77sgqpbTIr_Zt1 2 pVWDEz 3BQ 2 tg buCeoOotAkV8DaFD6 1 UkXQ3iaNJ 2 vwfw ALTqPt7JUSLrl 1 QTEzV6tp 3 9cy_y_RNRwex8j7224hz wJlbqIU 4e1l0pO8eFjZwkDo 2 eiuF7a_ 6mbCu5zA 1 xy6QBr8ECi 3 ldaKLZb1oS1sS PezeyUurYoz7N1iGU _Yej1PrINty...