QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#196392#6515. Path Planningucup-team870#WA 14ms3868kbC++141.2kb2023-10-01 16:47:232023-10-01 16:47:25

Judging History

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

  • [2023-10-01 16:47:25]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3868kb
  • [2023-10-01 16:47:23]
  • 提交

answer

#include <bits/stdc++.h>
#define For(i,l,r) for(int i=l; i<=r; i++)
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
using namespace std;
struct node{
    int x,y;
    friend bool operator <(node n,node m){
        return n.x==m.x?n.y<m.y:n.x<m.x;
    }
};
set<node> s;
node a[1000005];
int main(){
    IOS
    int _; cin>>_;
    while(_--){
        int n,m,x; cin>>n>>m;
        For(i,0,n-1) For(j,0,m-1){
            cin>>x; a[x]=node{i,j};
        }
        s.clear();
        For(i,0,n*m-1){
            s.insert(a[i]);
            auto it=s.lower_bound(a[i]);
            if (it!=s.begin()){
                --it;
                node o=*it;
                //cout<<o.x<<' '<<o.y<<' '<<a[i].x<<' '<<a[i].y<<endl;
                if (o.x<a[i].x&&o.y>a[i].y) {printf("%d\n",i); goto E;}
            }
            ++it;
            if (it!=s.end()){
                node o=*it;
                //cout<<o.x<<' '<<o.y<<' '<<a[i].x<<' '<<a[i].y<<endl;
                if (a[i].x<o.x&&a[i].y>o.y) {printf("%d\n",i); goto E;}
            }
        }
        printf("%d\n",n*m);
        E:;
    }
}
/*
2
2 3
1 2 4
3 0 5
1 5
1 3 0 4 2
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 14ms
memory: 3764kb

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
15
13
5
9
7
8
6
13
7
4
6
7
17
13
11
9
6
1
8
7
4
2
12
5
22
6
13
3
7
7
9
2
1
6
6
10
8
5
2
5
2
5
7
13
6
13
2
10
3
7
9
8
4
11
3
3
3
5
8
4
7
7
7
8
8
6
6
8
3
7
7
13
3
3
15
7
4
3
10
5
12
9
2
16
7
9
5
10
9
8
3
10
2
11
4
8
11
10
5
4
10
6
7
5
9
4
10
11
3
5
4
5
7
4
8
4
12
5
4
5
12
6
14
3
8
12
3
7
1...

result:

wrong answer 7th numbers differ - expected: '14', found: '15'