QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#545994#4374. What Really Happened on Mars?PhantomThreshold#RE 1ms4068kbC++202.6kb2024-09-03 18:44:322024-09-03 18:44:32

Judging History

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

  • [2024-09-03 18:44:32]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:4068kb
  • [2024-09-03 18:44:32]
  • 提交

answer

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

const int maxn = 300;

int n,R;
vector<int>E[10005];

int bi[maxn],cb[maxn];
queue< pair<int,int> >q[maxn];
int v[maxn];
int go[maxn],match[maxn];
int ans[maxn];

int main()
{
    ios_base::sync_with_stdio(false);

    cin>>n>>R;
    for(int i=1;i<=n;i++)
    {
        int ti,k;
        cin>>ti>>bi[i]>>k;
        E[ti].push_back(i);
        while(k--)
        {
            string str; int x=0;
            cin>>str; int sn= (int)str.length();
            for(int j=1;j<sn;j++) x=x*10+str[j]-'0';
            if(str[0]=='C') q[i].emplace( 0,x );
            else if(str[0]=='L') q[i].emplace( 1,x ), cb[x]=max(cb[x],bi[i]);
            else q[i].emplace( 2,x );
        }
    }

    int T=0,un=0;
    while( un!=n )
    {
    //    cerr<<T<<endl;

    //    if(T==3)
    //        int kk=1;

        int mxb=0,mxcb=0;
        for(int i=1;i<=n;i++) if(v[i])
        {
            if(mxb==0 || bi[mxb]<bi[i]) mxb=i;
            auto [ty,j]= q[i].front();
            if( ty==1 ) go[i]= match[j];
            else go[i]=0;
        }
        for(int i=1;i<=R;i++) if(match[i])
        {
            if(mxcb==0 || cb[mxcb]<cb[i]) mxcb=i;
        }

        if(mxb==0)
        {
            T++;
            for(auto i:E[T]) v[i]=1;
            continue;
        }
        
        int x;
        if( q[mxb].front().first==1 && bi[mxb]<=cb[mxcb] ) x=match[mxcb];
        else x=mxb;
        while(go[x]) x=go[x];

        {
            auto &[ty,j]=q[x].front();
            if(ty==0)
            {
                T++;
                for(auto i:E[T]) v[i]=1;
                j--;
                if(j==0)
                {
                    q[x].pop();
                    if(q[x].empty())
                    {
                        v[x]=0;
                        un++;
                        ans[x]=T;
                    }
                }
            }
            else if(ty==1)
            {
                match[j]=x;
                    q[x].pop();
                    if(q[x].empty())
                    {
                        v[x]=0;
                        un++;
                        ans[x]=T;
                    }
            }
            else
            {
                match[j]=0;
                    q[x].pop();
                    if(q[x].empty())
                    {
                        v[x]=0;
                        un++;
                        ans[x]=T;
                    }
            }
        }
    }
    for(int i=1;i<=n;i++) cout<<ans[i]<<'\n';

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3776kb

input:

3 1
50 2 5 C1 L1 C1 U1 C1
1 1 5 C1 L1 C100 U1 C1
70 3 1 C1

output:

106
107
71

result:

ok 3 lines

Test #2:

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

input:

3 3
5 3 5 C1 L1 C1 U1 C1
3 2 9 C1 L2 C1 L3 C1 U3 C1 U2 C1
1 1 9 C1 L3 C3 L2 C1 U2 C1 U3 C1

output:

8
15
16

result:

ok 3 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

19 8
7 7 23 L8 C5 C1 C1 L1 U1 L5 L3 U3 U5 U8 C1 C4 L3 L1 C2 U1 U3 L3 C2 C4 U3 C2
19 14 6 L7 L3 L4 U4 U3 U7
6 5 3 L1 U1 C5
35 2 18 L2 L5 L7 U7 C3 C3 C3 U5 U2 L4 L1 C2 C2 C5 U1 U4 L3 U3
45 6 3 C3 L6 U6
32 3 10 C4 C1 C3 L1 L6 L8 C2 U8 U6 U1
17 17 50 L4 L6 C4 L8 U8 U6 U4 L1 L5 L2 L8 L4 L3 L7 L6 U6 U7 U3...

output:

329
136
337
379
332
361
106
307
1
251
285
209
419
59
136
201
351
114
57

result:

ok 19 lines

Test #4:

score: 0
Accepted
time: 1ms
memory: 3764kb

input:

15 6
35 14 45 L2 L6 L3 L5 L1 L4 C2 C5 C1 C1 C4 C5 C4 C1 C4 C4 C1 C1 C3 C4 C4 C2 C2 C5 C2 C5 C3 C5 C2 C2 C5 C5 C2 C4 U4 U1 U5 U3 U6 L6 C3 L3 U3 U6 U2
3 7 17 L4 U4 L6 L3 L1 C2 U1 C5 U3 U6 L3 L4 L5 U5 C2 U4 U3
32 13 19 L1 L3 L5 C5 U5 U3 L2 L4 C2 U4 U2 L3 C5 C4 L5 U5 C4 U3 U1
18 4 44 L2 L5 L4 L3 L6 L1 C...

output:

130
12
150
382
127
289
247
253
218
175
414
218
197
417
487

result:

ok 15 lines

Test #5:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

20 1
42 1 34 C1 L1 C5 C3 C5 C1 C3 U1 L1 C4 C2 C2 C3 C1 C1 C1 U1 C3 C3 C3 L1 C4 C5 C2 U1 C1 C1 L1 C2 C5 U1 C2 C3 C4
5 11 20 C3 L1 U1 L1 C1 C5 C4 C2 C4 C1 C3 C1 C4 C4 C2 C3 C4 C5 C3 U1
40 6 21 L1 C5 C3 C5 C1 C2 C3 C2 C5 C4 C4 C2 C4 C4 C5 C3 C4 C3 C1 C1 U1
45 16 43 L1 C2 C3 C2 C5 C3 C4 C2 C1 C1 C2 C1 C...

output:

1757
923
1361
547
747
444
172
554
1257
1300
1023
1582
1157
423
1471
874
320
129
653
1687

result:

ok 20 lines

Test #6:

score: 0
Accepted
time: 1ms
memory: 3800kb

input:

20 3
37 18 29 L2 C1 L3 L1 C4 C5 C4 C2 U1 U3 U2 C4 C2 L1 L3 L2 C1 C1 C2 C3 C5 C3 C3 C3 C4 C4 U2 U3 U1
3 1 32 L1 L2 L3 C1 C2 C5 C3 C4 C3 C4 C5 C4 C4 C1 C1 C3 C1 C2 U3 L3 C5 C3 C5 C2 C4 C2 C3 C5 U3 U2 U1 C5
34 13 14 C1 L2 L3 C3 C1 C4 C4 C2 L1 C1 C3 U1 U3 U2
42 9 43 L2 L1 L3 C4 C4 U3 L3 C2 C2 C4 C3 C4 U...

output:

156
991
461
698
490
703
105
98
610
922
383
986
558
442
781
362
243
765
786
885

result:

ok 20 lines

Test #7:

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

input:

19 8
29 10 9 L6 L5 L8 L3 C4 U3 U8 U5 U6
30 9 14 L2 L5 L7 L1 C5 C3 U1 C3 U7 C1 C4 C2 U5 U2
20 7 44 L6 C4 L2 U2 U6 L4 C5 U4 L1 U1 L3 L4 C5 C2 U4 C5 L7 L1 L6 L2 C4 U2 U6 U1 U7 L8 U8 L8 U8 L6 C3 U6 C2 C2 L2 C3 U2 C1 L1 U1 C1 U3 L5 U5
46 12 39 L2 L5 L1 L4 L7 C3 U7 U4 U1 L8 C5 C1 U8 L1 C5 C2 C5 L3 L4 C3 L...

output:

190
208
284
186
58
359
344
71
39
63
387
147
247
71
9
115
39
307
298

result:

ok 19 lines

Test #8:

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

input:

18 5
36 8 23 L5 L1 L4 L2 L3 C3 C5 U3 U2 L2 C4 L3 U3 C5 L3 U3 U2 L2 C2 U2 U4 U1 U5
44 5 30 L2 C3 C1 L4 U4 C4 C5 U2 L4 U4 C5 L5 C3 L1 U1 C5 C4 C5 L1 U1 U5 L1 L5 C3 U5 U1 C2 L4 U4 C5
38 15 44 L2 C5 C3 U2 C1 L5 C4 U5 C2 C2 L2 C5 C4 C4 L1 L5 L3 C5 U3 C4 C5 L3 U3 L4 U4 L4 U4 C3 U5 U1 L1 L5 C1 C1 C4 U5 L3 ...

output:

266
400
146
154
469
236
404
35
28
355
446
287
214
174
78
196
80
247

result:

ok 18 lines

Test #9:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

13 4
3 8 3 L2 C5 U2
39 9 29 L3 C5 C2 U3 L3 L2 U2 U3 C5 C4 C1 L2 L3 C5 L1 C5 L4 C4 U4 U1 U3 U2 L1 C3 C5 U1 C3 C5 C4
17 11 32 C4 L4 U4 L2 L3 L1 L4 U4 U1 U3 U2 L1 L4 U4 U1 L1 L4 U4 L2 U2 C5 C3 C1 L4 U4 L3 C1 C3 U3 U1 C4 C5
27 2 18 L2 L4 C3 C2 C2 L1 C5 U1 U4 U2 L3 L4 L2 L1 U1 U2 U4 U3
12 13 16 L1 L2 U2 ...

output:

8
125
43
479
17
518
365
302
74
201
467
163
1

result:

ok 13 lines

Test #10:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

18 10
18 7 8 L10 L7 L5 U5 U7 U10 L1 U1
18 12 48 L3 L9 U9 U3 C3 L8 L1 L5 C5 C5 U5 U1 U8 C1 C2 L2 C3 C3 L7 C1 C2 U7 U2 L4 L6 U6 L2 L6 L5 L7 L9 L3 C5 U3 U9 U7 U5 U6 U2 U4 L3 L2 L4 L10 U10 U4 U2 U3
26 14 15 L8 U8 L10 C2 C2 C2 U10 L6 L4 C3 L7 C2 U7 U4 U6
41 9 4 L1 C3 C5 U1
28 11 33 L5 L9 C2 U9 U5 C1 C5 C...

output:

353
227
171
308
263
412
50
400
353
300
381
166
113
23
77
200
455
412

result:

ok 18 lines

Test #11:

score: -100
Runtime Error

input:

19 11
9319 4 15 L1 C84 U1 L11 L4 U4 L1 C36 L7 C53 U7 U1 C45 C39 U11
1644 15 60 L7 L2 C11 U2 L8 C99 C26 L5 L9 L4 L1 C81 L11 U11 C25 U1 U4 U9 U5 L1 U1 C77 L4 L10 L9 U9 L6 L3 L1 L5 U5 L5 L9 U9 U5 U1 U3 U6 L6 U6 U10 U4 L5 L2 L9 L3 C67 C6 L6 U6 U3 C57 U9 C11 C100 C20 U2 U5 U8 U7
100 11 64 L4 L10 C30 U10 ...

output:


result: