QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#693829#6439. Cloud Retainer's GameRegistrationError#AC ✓536ms22080kbC++201.3kb2024-10-31 16:48:522024-10-31 16:48:53

Judging History

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

  • [2024-10-31 16:48:53]
  • 评测
  • 测评结果:AC
  • 用时:536ms
  • 内存:22080kb
  • [2024-10-31 16:48:52]
  • 提交

answer

#include <bits/stdc++.h>
#define all(a) begin(a), end(a)
#define sz(a) (int) (a).size()
#define int long long
using namespace std;
const int N=100050;
int h,n,m,x[N],y[N];
struct coord{
    int x,y,ty;
    bool operator < (const coord &another){
        return x<another.x;
    }
    int f(int dir){
        if (dir){
            return (x-y+2*h)%(2*h);
        }else{
            return (x+y)%(2*h);
        }
    }
};
vector<coord> srt;
map<int,int> dp;
void solve() {
    cin>>h>>n;
    for (int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    cin>>m;
    srt.resize(n+m);
    for (int i=0;i<n;i++) srt[i]={x[i],y[i],0};
    for (int i=0;i<m;i++){
        cin>>srt[n+i].x>>srt[n+i].y;
        srt[n+i].ty=1;
    }
    sort(all(srt));
    dp.clear();
    dp[0]=1;
    for (auto i:srt){
        int to[2]={dp[i.f(0)],dp[i.f(1)]};
        if (i.ty){
            if (to[0]) to[0]++;
            if (to[1]) to[1]++;
        }else{
            to[0]=max(to[0],to[1]);
            to[1]=max(to[0],to[1]);
        }
        dp[i.f(0)]=to[0];
        dp[i.f(1)]=to[1];
    }
    int ans=0;
    for (auto i:dp){
        if (i.second) ans=max(ans,i.second-1);
    }
    cout<<ans<<"\n";
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(false);

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
4
3
1 1
2 2
6 2
4
3 1
3 3
5 1
7 3
3
1
4 2
3
1 1
6 2
9 1

output:

3
3

result:

ok 2 number(s): "3 3"

Test #2:

score: 0
Accepted
time: 291ms
memory: 10260kb

input:

5503
10
19
2 4
2 8
8 3
8 4
8 7
2 7
2 6
1 5
3 2
6 4
2 1
4 5
2 5
7 1
4 7
5 7
2 2
8 6
8 1
12
5 1
4 8
5 2
6 1
3 6
1 1
1 7
7 2
5 6
6 8
1 2
3 5
10
5
9 5
10 7
6 6
5 7
1 3
9
6 8
8 8
6 4
2 9
5 4
4 2
10 9
2 3
2 1
7
1
4 3
14
4 6
6 1
2 1
7 6
2 3
4 4
5 3
6 5
1 4
3 4
3 2
6 2
8 6
8 2
6
6
5 2
5 1
3 1
2 3
7 4
5 5
3
...

output:

2
1
2
1
3
2
0
2
4
6
1
2
0
0
1
2
1
1
0
1
0
0
2
1
1
3
2
3
3
2
1
2
0
1
5
1
1
1
0
1
3
1
2
3
3
3
2
1
0
3
1
2
2
0
4
1
1
0
1
2
2
2
1
1
1
1
2
3
2
2
2
1
1
3
1
3
0
0
3
4
5
1
1
1
1
1
0
2
0
0
3
0
2
1
1
1
0
3
2
1
3
4
3
2
2
4
2
4
2
1
2
1
0
1
3
0
3
0
2
1
0
2
5
1
2
2
1
0
1
3
0
2
3
1
4
2
2
0
2
3
2
0
0
3
1
1
1
1
3
2
...

result:

ok 5503 numbers

Test #3:

score: 0
Accepted
time: 536ms
memory: 22080kb

input:

54
83
1995
54 14
42 63
23 55
46 52
94 71
16 18
51 54
62 47
90 38
42 50
82 20
8 28
52 64
49 19
56 5
10 74
99 30
90 42
48 2
11 78
4 38
78 77
26 26
47 12
82 60
41 17
87 2
37 16
51 15
32 63
88 82
76 33
44 10
94 28
31 5
30 80
29 19
35 70
88 78
39 69
40 5
84 52
87 59
54 36
34 76
88 42
42 37
79 70
27 77
19...

output:

47
32
32
32
38
32
39
33
39
40
36
32
36
32
46
30
35
41
40
36
108
90
98
81
166
115
106
170
148
113
198
72
57
202
337
153
186
978
87
886
151
489
111
112
90
154
174
188
266
59
10210
1041
87
981

result:

ok 54 numbers