QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#621123#8230. SubmissionswxgmjfhyWA 83ms3704kbC++203.1kb2024-10-08 09:29:562024-10-08 09:29:57

Judging History

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

  • [2024-10-08 09:29:57]
  • 评测
  • 测评结果:WA
  • 用时:83ms
  • 内存:3704kb
  • [2024-10-08 09:29:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

struct team{
    int cnt,tim;
    vector<pair<int,int> >v[26];

    team():cnt(0),tim(0){
        for(int i=0;i<26;i++)v[i].clear();
    }

    inline int insert(int op,int tim,int flag){
        v[op].push_back({tim,flag});
        return v[op].size()-1;
    }

    inline void cal(int x=-1,int y=-1){
        cnt=tim=0;

        for(int i=0;i<26;i++){
            int sub=0,n=v[i].size();

            for(int j=0;j<n;j++){
                auto [T,f]=v[i][j];

                if(x==i&&y==j)f^=1;

                if(f){
                    cnt++;
                    tim+=T+sub*20;
                    break;
                }

                sub++;
            }
        }
    }

    inline bool empty()const{
        for(int i=0;i<26;i++){
            if(v[i].size())return false;
        }

        return (cnt==0)&&(tim==0);
    }

    inline bool legal()const{
        return cnt>0;
    }
};

struct judge{
    int cnt,tim,id;

    bool operator<(const judge &t)const{
        if(cnt==t.cnt)return tim<t.tim;
        return cnt>t.cnt;
    }
};

int m;

string s;
char ch;
int id,op,tim,flag;

inline void solve(){
    cin>>m;

    int cnt=0;
    map<string,int>mp;
    vector<string>name(1);

    vector<team>a(1);
    vector<array<int,3> >v(m);

    for(int i=0;i<m;i++){
        cin>>s>>ch>>tim;

        if(mp.find(s)==mp.end()){
            mp[s]=++cnt;
            a.push_back({});

            assert(a[cnt].empty());

            name.push_back(s);
        }

        id=mp[s],op=ch-'A';

        assert(0<=op&&op<26);

        cin>>s;

        assert(s[0]=='a'||s[0]=='r');

        v[i]={id,op,a[id].insert(op,tim,(s[0]=='a'?1:0))};
    }

    assert(a.size()-1==cnt);
    assert(a.size()==name.size());

    for(int i=1;i<=cnt;i++)a[i].cal();

    int sol=0;
    multiset<judge>s;

    auto del=[&](int i)->void {
        s.extract({a[i].cnt,a[i].tim,i});
        if(a[i].legal())sol--;
    };

    auto add=[&](int i)->void {
        s.insert({a[i].cnt,a[i].tim,i});
        if(a[i].legal())sol++;
    };

    for(int i=1;i<=cnt;i++)add(i);

    vector<int>ans(cnt+1);

    auto check=[&]()->void {
        assert(s.size()==cnt);
        assert(sol<=cnt);

        int line=min((sol+9)/10,35);
        if(!line)return;

        auto it=s.begin();
        for(int i=0;i<line;i++){
            ans[it->id]=1;
            it++;
        }

        while(it!=s.end()&&(prev(it)->cnt==it->cnt&&prev(it)->tim==it->tim)){
            ans[it->id]=1;
            it++;
        }
    };

    check();

    for(const auto &[i,op,j]:v){
        del(i);
        a[i].cal(op,j);
        add(i);
        
        check();
        
        del(i);
        a[i].cal();
        add(i);
    }

    cout<<accumulate(ans.begin(),ans.end(),0)<<"\n";

    for(int i=1;i<=cnt;i++){
        if(ans[i])cout<<name[i]<<" ";
    }

    cout<<"\n";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t=1;
    cin>>t;
    while(t--)solve();

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

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: 0
Accepted
time: 0ms
memory: 3632kb

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: 3652kb

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 K B C D E F G H I J 
1
A 

result:

ok 2 test cases ok. (2 test cases)

Test #4:

score: 0
Accepted
time: 0ms
memory: 3584kb

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: 82ms
memory: 3576kb

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
4Vf...

result:

ok 100000 test cases ok. (100000 test cases)

Test #6:

score: -100
Wrong Answer
time: 83ms
memory: 3704kb

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
tsd Qua1Pti3vKhyQKDUm fYuK1KNkuyO5HRCq xiLm0TUOF3T 
2
t3 JP 
2
fhYPGC8W82NwJTQL 77sgqpbTIr_Zt1 
2
pVWDEz 3BQ 
2
tg buCeoOotAkV8DaFD6 
1
UkXQ3iaNJ 
2
ALTqPt7JUSLrl vwfw 
1
QTEzV6tp 
3
4e1l0pO8eFjZwkDo wJlbqIU 9cy_y_RNRwex8j7224hz 
2
eiuF7a_ 6mbCu5zA 
1
xy6QBr8ECi 
3
ldaKLZb1oS1sS _Yej1PrINtydmOudwo...

result:

wrong answer at least one of the names are different in the case 755. (test case 755)