QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#508423#7660. Investigating Frog Behaviour on Lily Pad PatternsAu_GoldTL 81ms30596kbC++201.4kb2024-08-07 15:11:162024-08-07 15:11:16

Judging History

This is the latest submission verdict.

  • [2024-08-07 15:11:16]
  • Judged
  • Verdict: TL
  • Time: 81ms
  • Memory: 30596kb
  • [2024-08-07 15:11:16]
  • Submitted

answer

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<string>
#include<iomanip>
#include<cmath>
#include<set>
using namespace std;
using ll = long long;
#define int ll

const int mxn = 1e6 + 2e5 + 5;


void solve()
{
    int n;
    cin >> n;
    vector<int> emp, fp(mxn);
    for (int i = 0; i <= mxn; i++)
    {
        emp.push_back(i);
    }
    for (int i = 1; i <= n; i++)
    {
        int p;
        cin >> p;
        fp[i] = p;
        int pos = upper_bound(emp.begin(), emp.end(), p) - emp.begin() - 1;
        emp.erase(emp.begin() + pos);
    }
    int q;
    cin >> q;
    while (q--)
    {
        int idx;//青蛙编号
        cin >> idx;
        int p = fp[idx];//当前位置
        int d = emp[upper_bound(emp.begin(), emp.end(), p) - emp.begin()];//落点
        fp[idx] = d;
        cout << d << endl;
        //删落点
        int lp = upper_bound(emp.begin(), emp.end(), d) - emp.begin() - 1;
        emp.erase(emp.begin() + lp);
        //初始位置变空
        int pos = upper_bound(emp.begin(), emp.end(), p) - emp.begin();
        emp.insert(emp.begin() + pos, p);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int T = 1;
    //cin >> T;
    while (T--)
    {
        solve();
    }

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 25ms
memory: 30596kb

input:

5
1 2 3 5 7
3
1
2
4

output:

4
6
8

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 28ms
memory: 30372kb

input:

5
1 2 3 5 7
4
1
1
1
1

output:

4
6
8
9

result:

ok 4 lines

Test #3:

score: 0
Accepted
time: 81ms
memory: 28952kb

input:

5
1 2 3 4 5
20
1
4
4
3
5
3
3
5
2
2
5
4
1
4
2
3
1
5
3
3

output:

6
7
8
4
7
5
9
10
3
4
11
10
7
12
5
10
8
13
11
14

result:

ok 20 lines

Test #4:

score: -100
Time Limit Exceeded

input:

10
2 4 6 7 8 9 10 12 13 14
1000
4
5
4
6
2
5
2
9
6
10
6
2
1
3
7
3
9
5
2
10
8
7
6
7
4
7
9
4
4
4
5
2
6
1
10
9
10
3
7
10
5
9
5
8
4
8
10
9
1
7
10
8
10
6
7
7
10
8
1
2
9
10
2
3
8
7
2
7
2
2
1
10
3
3
2
8
9
6
10
1
7
9
10
6
5
9
9
6
4
9
10
3
3
10
5
4
8
5
8
4
9
5
5
3
9
7
5
5
4
6
1
8
6
7
9
2
2
4
9
3
6
4
6
8
4
4
3...

output:

11
15
16
11
5
17
7
15
13
18
14
8
3
7
11
9
19
20
10
21
13
12
15
14
17
16
22
18
19
23
24
11
17
4
25
26
27
10
18
28
25
27
26
14
24
15
29
28
5
19
30
16
31
18
20
21
32
17
6
12
29
33
13
11
19
22
14
23
15
16
7
34
12
13
17
20
30
19
35
8
25
31
36
21
27
32
33
22
26
34
37
14
15
38
28
27
21
29
23
28
35
30
31
16...

result: