QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#350936#6515. Path PlanningUser0069AC ✓1041ms81768kbC++141.5kb2024-03-11 10:08:482024-03-11 10:08:50

Judging History

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

  • [2024-03-11 10:08:50]
  • 评测
  • 测评结果:AC
  • 用时:1041ms
  • 内存:81768kb
  • [2024-03-11 10:08:48]
  • 提交

answer

#include<bits/stdc++.h>
#define taskname ""
#define el '\n'
#define fi first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define int ll
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
#define Faster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=2e6+6;
const int INF=1e9;
const int mod=1e9+7;
int m,n,x[maxn],y[maxn];
struct P
{
    int x,y;
}p[maxn];
bool operator <(P a,P b)
{
    if(a.x==b.x) return a.y<b.y;
    return a.x<b.x;
}
bool operator ==(P a,P b)
{
    return a.x==b.x&&a.y==b.y;
}
set<P> s;
void solve()
{
    cin>>n>>m;
    s.clear();
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            int xx;
            cin>>xx;
            p[xx].x=i;
            p[xx].y=j;
        }
    }
    s.insert(p[0]);
    for(int i=1;i<=n*m-1;i++)
    {
        bool can=1;
        auto it=s.lower_bound(p[i]);
        if(it!=s.end()&&it->y<p[i].y) can=0;
        if(it!=s.begin())
        {
            --it;
            if(it->y>p[i].y) can=0;
        }
        if(!can) break;
        s.insert(p[i]);
    }
    cout<<s.size()<<"\n";
}
signed main()
{
    if (fopen(taskname".INP","r"))
    {
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    Faster
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 3
1 2 4
3 0 5
1 5
1 3 0 4 2

output:

3
5

result:

ok 2 number(s): "3 5"

Test #2:

score: 0
Accepted
time: 12ms
memory: 3668kb

input:

10000
2 9
4 0 3 5 2 7 16 11 12
9 13 14 17 10 8 15 1 6
4 8
19 23 22 13 29 4 17 26
30 6 25 3 15 24 18 14
12 8 7 9 27 5 0 10
11 16 31 20 2 28 1 21
1 6
3 2 0 1 4 5
2 3
4 2 0
3 5 1
5 1
4
0
3
2
1
1 3
1 0 2
8 10
9 50 8 0 41 57 60 30 23 65
64 21 36 12 10 5 58 19 38 67
71 52 45 17 77 4 59 51 22 25
56 49 79 2...

output:

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

result:

ok 10000 numbers

Test #3:

score: 0
Accepted
time: 64ms
memory: 4400kb

input:

100
99 83
18 2823 5680 5151 2684 3362 1063 6836 6834 7934 3158 5909 240 2112 8046 5303 905 828 6380 7747 3343 8119 3117 7501 5852 647 1289 6598 1435 4242 7890 5768 7195 2462 2667 2558 4378 6487 4762 4646 6566 3900 2991 5329 3203 3889 5008 6833 3557 1601 5516 6124 6441 311 6600 4025 3961 7575 1861 44...

output:

128
125
58
84
3
158
124
104
10
178
141
49
16
142
176
161
96
62
158
136
59
91
97
7
44
86
106
34
58
3
152
38
152
7
150
78
17
128
136
38
160
88
29
28
104
118
74
121
162
118
1243
1548
701
204
931
10000
1249
467
1752
947
863
419
597
1603
3228
1210
1481
916
10000
427
728
10000
37
10000
251
2705
606
10000
...

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 110ms
memory: 19384kb

input:

1
1000 1000
1283 449486 175160 239276 255441 328929 747766 698005 955583 292742 137449 351560 609063 788395 493817 785822 140814 129116 248470 922611 720697 587047 952796 209319 404424 668084 289477 561080 605648 815597 173174 255440 699751 101977 71754 783062 643174 341132 283279 686934 836019 5184...

output:

1340

result:

ok 1 number(s): "1340"

Test #5:

score: 0
Accepted
time: 136ms
memory: 20512kb

input:

1
10 100000
689191 646425 545223 281210 519035 981365 700560 96123 320469 291369 130877 221569 929695 954548 480774 735565 714873 594353 871164 643780 545198 845640 62782 16531 4650 861127 122704 476178 962959 458750 10601 32275 334992 523897 495155 312669 15958 118063 8293 817200 309588 455968 1246...

output:

19513

result:

ok 1 number(s): "19513"

Test #6:

score: 0
Accepted
time: 942ms
memory: 81760kb

input:

1
1 1000000
964027 632704 66395 804059 548859 444426 284847 628164 468888 888960 42544 747789 917317 43678 461194 470196 350519 775162 676379 843319 777632 978840 458784 778592 868035 284605 670109 324535 363851 771999 520817 356682 436218 216024 424504 661414 43490 761116 594749 572176 171775 84082...

output:

1000000

result:

ok 1 number(s): "1000000"

Test #7:

score: 0
Accepted
time: 136ms
memory: 21596kb

input:

1
100000 10
9342 337052 637551 237232 240390 140345 751420 910235 572040 936221
35876 527927 858263 672768 426548 397031 116782 140422 778244 143078
22275 530528 934900 185332 532833 126307 835088 932404 591441 186912
892535 848088 254807 266002 249992 991443 303837 155697 955416 804943
34683 804818...

output:

36532

result:

ok 1 number(s): "36532"

Test #8:

score: 0
Accepted
time: 1041ms
memory: 81768kb

input:

1
1000000 1
7755
75835
649678
733241
406031
185482
391646
162200
863495
821948
667415
271339
158676
484133
320762
807663
11813
241913
924788
7753
663182
922182
815882
517922
648589
336446
940797
762876
687005
314575
329557
740437
547923
542219
215537
832729
201673
685747
525021
683572
121085
838332
...

output:

1000000

result:

ok 1 number(s): "1000000"