QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#167738#4092. 진화Lynkcat#5 597ms80004kbC++202.0kb2023-09-07 17:01:202024-07-04 02:41:33

Judging History

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

  • [2024-07-04 02:41:33]
  • 评测
  • 测评结果:5
  • 用时:597ms
  • 内存:80004kb
  • [2023-09-07 17:01:20]
  • 提交

answer

#include "evolution.h"
#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
// #define int ll
#define N 500005
using namespace std;
namespace 
{
    int n;
    multiset<int>S[N],all;
    int dis[N],ans[N];
    int ffa[N];
}
inline int mx(multiset<int>&s)
{
    if (s.empty()) return 0;
    return (*--s.end());
}
inline int smx(multiset<int>&s)
{
    if (s.size()<=1) return 0;
    return (*(--(--s.end())))+1;
}
inline int ssmx(multiset<int>&s)
{
    if (s.size()<=2) return 0;
    return (*(--(--(--s.end()))))+1;
}
inline int qry(int k)
{
    return max(mx(S[k]),smx(S[k]));
}
inline int qry1(int k)
{
    return max({mx(S[k])+smx(S[k]),smx(S[k])+ssmx(S[k])});
}
void init()
{
    n=1;
    all.insert(qry1(1));
}
void work(int k,int x)
{
    if (k==1) return;
    int fa=ffa[k];
    // cout<<k<<" "<<x<<" "<<ans[k]<<" "<<dis[k]<<" "<<qry1(k)<<" "<<S[k].size()<<endl;
    S[fa].insert(dis[k]);
    bool bl=1;
    all.erase(all.find(ans[fa]));

    bl&=(ans[fa]==max(x,qry1(fa)));
    bl&=(dis[fa]==qry(fa));
    // cout<<k<<" "<<x<<" "<<fa<<endl;

    ans[fa]=qry1(fa);
    all.insert(ans[fa]);
    // cout<<k<<" "<<x<<" "<<fa<<endl;
    // 
    if (bl) return;
    if (fa!=1) S[ffa[fa]].erase(S[ffa[fa]].find(dis[fa]));
    // cout<<k<<" "<<x<<" "<<fa<<endl;
    dis[fa]=qry(fa);
    work(fa,ans[fa]);
}

void observation(int P)
{
    ++n;
    ffa[n]=P;
    all.insert(qry1(n));
    work(n,0);
    // cout<<endl;
    // for (int i=1;i<=n;i++) cout<<ans[i]<<' ';
    // cout<<endl;
    // for (int i=1;i<=n;i++) cout<<dis[i]<<' ';
    // cout<<endl;
    // for (int i=1;i<=n;i++) cout<<mx(S[i])<<' ';
    // cout<<endl;
    // for (int i=1;i<=n;i++) cout<<smx(S[i])<<' ';
    // cout<<endl;
}
int analyze(int R)
{
    return ans[R];
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 7
Accepted
time: 4ms
memory: 28824kb

input:

30
1 1
2 1
2 1
2 1
2 2
1 1
1 3
2 1
2 4
2 3
1 3
1 5
1 4
1 2
2 5
1 7
1 4
2 7
2 7
2 3
1 3
2 6
1 10
1 1
2 13
2 2
1 6
1 1
2 12
1 3

output:

3989776153
7481903423
6741079408

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 4ms
memory: 28400kb

input:

30
2 1
1 1
2 1
1 1
2 3
2 2
2 2
1 3
1 3
1 5
2 3
2 6
2 5
1 5
2 3
1 1
1 5
2 5
1 6
2 10
1 8
1 1
2 7
1 4
2 1
2 12
1 5
1 10
2 15
1 14

output:

4085837229
8898398677
7224337819

result:

ok 3 lines

Test #3:

score: -7
Wrong Answer
time: 0ms
memory: 28452kb

input:

30
2 1
1 1
2 2
2 1
2 1
1 2
1 3
2 1
2 3
1 3
1 3
1 6
2 7
1 7
1 8
2 5
2 8
2 8
2 8
2 1
2 3
1 2
1 7
2 8
1 3
1 1
2 9
1 2
1 13
1 10

output:

3263323621
6991389469
6932599083

result:

wrong answer 1st lines differ - expected: '3655449673', found: '3263323621'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 5
Accepted

Test #98:

score: 5
Accepted
time: 529ms
memory: 79060kb

input:

1000000
2 1
1 1
1 1
1 2
2 4
1 2
2 1
1 3
1 3
1 4
2 1
1 4
1 5
1 5
2 3
2 4
2 2
1 6
1 6
2 9
1 7
2 2
1 7
2 2
2 3
1 8
2 4
2 9
2 2
1 8
1 9
1 9
2 1
2 4
2 1
2 4
2 6
2 3
2 4
1 10
1 10
2 3
1 11
2 2
2 13
1 11
2 1
1 12
1 12
1 13
1 13
2 1
2 5
1 14
2 3
2 4
1 14
1 15
2 5
1 15
1 16
1 16
1 17
1 17
1 18
1 18
2 10
2 7
...

output:

226384484418682
252721864385826
254136704849695

result:

ok 3 lines

Test #99:

score: 0
Accepted
time: 32ms
memory: 33132kb

input:

69000
1 1
2 2
1 1
1 2
1 2
2 2
2 1
1 3
2 4
2 4
1 3
2 1
2 1
2 4
2 3
1 4
2 6
2 1
1 4
1 5
1 5
1 6
2 5
1 6
1 7
2 3
1 7
1 8
2 5
1 8
2 10
1 9
1 9
1 10
2 1
2 6
2 7
2 2
2 3
1 10
2 2
2 2
1 11
1 11
2 1
1 12
1 12
2 5
1 13
1 13
1 14
2 1
1 14
1 15
1 15
2 4
2 3
2 1
1 16
1 16
1 17
2 3
1 17
1 18
1 18
1 19
1 19
1 20
...

output:

14784500253954
14669250414504
15283613553821

result:

ok 3 lines

Test #100:

score: 0
Accepted
time: 20ms
memory: 31608kb

input:

35000
1 1
2 1
1 1
2 1
1 2
1 2
2 3
2 1
2 2
2 1
1 3
1 3
2 1
1 4
2 8
2 4
1 4
1 5
2 3
2 5
1 5
1 6
2 2
2 5
1 6
1 7
1 7
2 5
1 8
2 5
2 1
2 4
2 9
1 8
1 9
1 9
1 10
1 10
1 11
2 3
2 6
2 3
2 5
2 1
1 11
2 4
1 12
2 3
2 8
1 12
1 13
1 13
2 3
2 7
2 1
1 14
1 14
1 15
2 5
1 15
2 3
1 16
1 16
1 17
1 17
2 2
1 18
1 18
2 18...

output:

6096455559752
6054967272968
6357768376585

result:

ok 3 lines

Test #101:

score: 0
Accepted
time: 200ms
memory: 48044kb

input:

450000
2 1
1 1
2 2
2 2
2 1
1 1
2 3
1 2
2 2
2 1
1 2
1 3
1 3
1 4
1 4
2 6
1 5
2 3
1 5
2 6
1 6
2 4
2 5
2 4
2 1
2 2
2 4
1 6
2 3
2 1
1 7
2 1
2 2
1 7
2 5
2 1
1 8
2 5
1 8
2 2
2 3
1 9
2 6
1 9
2 4
1 10
1 10
2 1
2 3
1 11
2 2
2 9
2 5
1 11
1 12
2 10
1 12
2 3
2 12
2 11
2 4
1 13
2 4
1 13
1 14
2 14
1 14
2 1
1 15
2 ...

output:

121665563089444
126544857831942
129761372078861

result:

ok 3 lines

Test #102:

score: 0
Accepted
time: 42ms
memory: 33060kb

input:

97000
2 1
1 1
2 2
1 1
2 2
2 2
2 1
2 1
2 2
1 2
2 2
1 2
1 3
1 3
2 4
2 3
1 4
2 3
2 3
2 2
2 1
2 1
1 4
2 4
2 3
2 4
1 5
1 5
2 3
1 6
1 6
1 7
1 7
2 1
2 8
1 8
2 3
2 2
1 8
1 9
2 3
2 6
2 9
1 9
2 2
2 2
2 6
1 10
1 10
1 11
1 11
1 12
1 12
2 2
2 6
1 13
2 2
1 13
2 6
1 14
2 2
1 14
2 4
1 15
2 1
1 15
2 1
2 1
2 1
1 16
2...

output:

25220690929170
25344636746902
26447936619463

result:

ok 3 lines

Test #103:

score: 0
Accepted
time: 360ms
memory: 63164kb

input:

840000
2 1
2 1
2 1
1 1
2 1
2 1
1 1
2 2
1 2
1 2
2 3
1 3
2 4
1 3
2 5
1 4
2 1
2 2
1 4
2 5
2 2
2 2
2 4
2 2
2 3
1 5
2 2
1 5
2 2
2 2
2 5
2 1
1 6
2 1
2 2
2 8
1 6
2 1
2 5
1 7
2 2
2 1
2 1
2 1
2 10
2 5
2 3
1 7
2 2
2 11
2 1
2 9
1 8
2 1
2 2
1 8
2 2
1 9
2 4
1 9
1 10
1 10
1 11
2 2
1 11
1 12
1 12
2 4
2 3
1 13
1 13...

output:

228116240634290
247830472818950
249540875626368

result:

ok 3 lines

Test #104:

score: 0
Accepted
time: 25ms
memory: 31504kb

input:

60000
1 1
2 1
1 1
1 2
2 2
1 2
1 3
1 3
2 2
2 2
1 4
1 4
1 5
2 2
2 2
1 5
1 6
1 6
1 7
2 7
1 7
2 3
1 8
1 8
1 9
2 7
2 10
1 9
1 10
1 10
1 11
1 11
1 12
1 12
2 2
2 4
2 1
2 3
1 13
1 13
2 1
2 1
2 3
1 14
2 3
1 14
2 4
2 8
2 5
1 15
1 15
1 16
2 11
1 16
2 3
1 17
2 7
2 5
1 17
1 18
1 18
1 19
1 19
2 2
1 20
2 2
2 10
2 ...

output:

13192477991316
13159119140522
13696711811391

result:

ok 3 lines

Test #105:

score: 0
Accepted
time: 3ms
memory: 29612kb

input:

6800
2 1
2 1
2 1
1 1
1 1
2 2
1 2
1 2
1 3
1 3
2 1
1 4
2 3
1 4
2 3
1 5
2 3
1 5
1 6
1 6
2 3
1 7
1 7
2 9
1 8
1 8
1 9
2 3
2 1
1 9
1 10
2 6
1 10
1 11
1 11
1 12
1 12
2 2
1 13
1 13
1 14
1 14
2 2
1 15
1 15
1 16
1 16
2 1
1 17
1 17
2 1
1 18
1 18
1 19
1 19
2 3
1 20
1 20
1 21
2 2
1 21
1 22
1 22
2 1
1 23
1 23
1 2...

output:

1180474027890
1141458473508
1221476654564

result:

ok 3 lines

Test #106:

score: 0
Accepted
time: 11ms
memory: 28916kb

input:

9800
2 1
2 1
2 1
2 1
2 1
1 1
1 1
1 2
2 3
2 4
1 2
1 3
2 2
1 3
2 4
2 3
1 4
1 4
1 5
1 5
2 2
1 6
2 3
1 6
2 1
2 3
1 7
2 4
2 2
1 7
1 8
2 3
1 8
1 9
2 1
2 1
2 2
2 3
2 9
1 9
1 10
2 6
1 10
2 11
1 11
2 13
1 11
1 12
1 12
2 8
2 2
2 5
2 7
1 13
2 5
2 11
2 4
2 5
2 7
1 13
2 7
2 2
1 14
2 11
2 9
1 14
1 15
1 15
1 16
1 ...

output:

2522281844666
2559303105128
2646473666443

result:

ok 3 lines

Test #107:

score: 0
Accepted
time: 10ms
memory: 29196kb

input:

10000
2 1
2 1
2 1
1 1
1 1
1 2
2 4
1 2
1 3
2 1
2 1
1 3
2 1
2 6
1 4
1 4
1 5
1 5
2 3
1 6
1 6
1 7
2 4
2 7
1 7
1 8
2 2
1 8
1 9
2 1
1 9
1 10
2 1
2 8
2 1
1 10
1 11
2 1
2 5
2 1
1 11
1 12
2 2
1 12
2 2
2 3
1 13
1 13
1 14
1 14
2 2
1 15
2 1
2 4
1 15
1 16
2 1
1 16
2 1
1 17
2 8
2 1
1 17
2 6
2 17
1 18
2 1
2 5
1 18...

output:

2489817197164
2536287789128
2651483685195

result:

ok 3 lines

Subtask #4:

score: 0
Wrong Answer

Test #108:

score: 0
Wrong Answer
time: 597ms
memory: 80004kb

input:

1000000
2 1
2 1
1 1
1 1
2 1
1 2
1 4
2 1
2 3
2 1
1 5
1 3
1 6
2 2
2 2
2 2
2 2
1 8
2 1
1 5
2 3
1 8
1 11
1 12
1 13
1 12
2 3
2 5
1 14
2 3
2 4
1 16
2 2
1 17
1 18
2 10
2 3
1 19
2 4
1 10
1 17
2 1
2 4
2 5
1 19
2 9
1 15
1 24
2 8
1 25
2 2
2 3
2 2
2 5
1 25
2 5
1 20
1 26
1 29
2 7
2 2
2 6
2 1
1 30
2 3
1 30
2 3
2 ...

output:

212762317175752
252691308609614
246789911174010

result:

wrong answer 1st lines differ - expected: '212888413200404', found: '212762317175752'

Subtask #5:

score: 0
Skipped

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%