QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#472902#6515. Path Planningzzisjtu#WA 17ms3600kbC++231.5kb2024-07-11 20:11:402024-07-11 20:11:41

Judging History

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

  • [2024-07-11 20:11:41]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:3600kb
  • [2024-07-11 20:11:40]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define all(x) x.begin(), x.end()
#define lowbit(i) ((i)&(-i))
#define pii pair<int,int>
#define endl '\n'
#define mk(x,y) make_pair(x,y)
#define popcount(x) __builtin_popcount(x)
#define LF(x) fixed<<setprecision(x)
const double pi=3.14159265358979323846;
const double eps=1e-9;
const int inf=1e9;
const long long INF=4e18;
const int mod=1e9+7;
using namespace std;
const int N=1e5+10;

void solve()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>>a(n+1,vector<int>(m+1));
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=m;j++){
    		cin>>a[i][j];
    	}
    }
    auto bfs=[&](){
    	queue<array<int,2>>q;
    	vector<int>ans;
    	q.push({1,1});
    	while(q.size()){
    		auto [x,y]=q.front();
    		ans.push_back(a[x][y]);
    		q.pop();
    		if(y+1<=m&&x+1<=n){
    			int x1=x+1,y1=y;
    			int x2=x,y2=y+1;
    			if(a[x1][y1]<a[x2][y2]){
    				q.push({x1,y1});
    			}
    			else q.push({x2,y2});
    		}
    		else if(y+1<=m){
    			q.push({x,y+1});
    		}
    		else if(x+1<=n)q.push({x+1,y});
    	}
    	return ans;
    };
    vector<int>ans=bfs();
    sort(all(ans));
    for(int i=0;i<ans.size();i++){
    	if(ans[i]!=i){
    		cout<<i<<endl;
    		return;
    	}
    }
    cout<<ans.size()<<endl;
}

int 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: 0ms
memory: 3540kb

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: 17ms
memory: 3600kb

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
0
6
3
5
3
14
13
5
9
3
7
6
9
7
0
6
7
13
9
0
0
0
0
0
7
4
0
10
1
18
0
12
3
7
6
6
1
1
5
6
1
8
4
2
5
1
5
7
13
0
10
2
10
3
6
9
8
2
3
2
3
0
0
8
4
7
7
7
8
8
6
6
5
0
7
7
0
2
3
6
0
1
3
10
2
9
7
2
2
0
0
0
0
9
0
3
1
2
5
3
8
4
10
4
0
10
4
6
5
1
4
10
6
3
5
1
0
7
1
8
0
12
0
4
0
7
5
8
3
7
9
3
0
2
4
6
0
2
10
2
1
3...

result:

wrong answer 2nd numbers differ - expected: '2', found: '0'