QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#405953 | #6515. Path Planning | xiaole | WA | 20ms | 3616kb | C++23 | 1.3kb | 2024-05-06 17:35:06 | 2024-05-06 17:35:07 |
Judging History
answer
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;using ll = long long;using PLL = pair<ll,ll>;
const ll MAX = 1e18;const ll MIN = -1e18;const ll INF=0x3f3f3f3f;
const ll Q = 2e5+9;const ll MOD = 1e9 + 7;
vector<vector<ll>> a,dp;
set<ll> ans;
void solve(){
ll n,m;cin>>n>>m;
a.resize(n+10);
dp.resize(n+10);
for (ll i = 0; i <= n; i++)
{
a[i].resize(m+10);
dp[i].resize(m+10);
}
for (ll i = 1; i <= n; i++)
{
for (ll j = 1; j <= m; j++)
{
cin>>a[i][j];
}
}
for (ll i = 1; i <= m; i++)
{
dp[1][i]=1;
}
for (ll i = 1; i <= n; i++)
{
dp[i][1]=2;
}
for (ll i = 2; i <= n; i++)
{
for (ll j = 2; j <= m; j++)
{
if(a[i-1][j]<a[i][j-1]) dp[i][j]=2;
else dp[i][j]=1;
}
}
ans.clear();
ll x=n,y=m;
while(x!=1 or y!=1){
ans.insert(a[x][y]);
if(dp[x][y]==1) y--;
else x--;
}
ans.insert(a[x][y]);
auto it=ans.begin();
ll now=0;
while(*it==now and it!=ans.end()){
now++;it++;
}
cout<<now<<"\n";
}
int main(){
ios;ll _=1;cin>>_;
while (_--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3600kb
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: 20ms
memory: 3616kb
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:
8 2 6 3 5 3 14 13 5 9 1 7 5 9 7 1 6 7 13 9 2 9 1 0 1 2 0 1 10 0 18 0 12 0 7 1 9 1 1 5 6 10 8 2 2 1 1 5 0 13 1 10 2 10 3 6 9 1 1 9 0 3 3 5 8 4 7 7 7 0 2 6 6 5 3 7 7 2 3 1 0 5 1 3 10 5 12 7 2 8 1 2 5 2 9 0 1 3 2 1 3 8 7 10 0 4 10 4 6 0 9 2 1 0 0 5 1 4 7 4 8 3 12 2 0 2 2 6 8 3 7 9 2 6 0 4 6 2 6 10 0 1 ...
result:
wrong answer 1st numbers differ - expected: '9', found: '8'