QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#473625#6515. Path Planningmufeng12WA 39ms3848kbC++231.8kb2024-07-12 11:46:202024-07-12 11:46:20

Judging History

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

  • [2024-07-12 11:46:20]
  • 评测
  • 测评结果:WA
  • 用时:39ms
  • 内存:3848kb
  • [2024-07-12 11:46:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define maxint INT32_MAX
#define minint INT32_MIN
#define maxll INT64_MAX
#define minll INT64_MIN
#define mod  998244353
#define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
#pragma GCC optimize(2)
void write(int x);
ll c[120][120];
char *p1,*p2,buf[100000];
int read();
const int N=1e5+10;
int fact[N],infact[N];
struct node{
    int v,w;
    bool operator < (const node& b) const{
        return v<b.v;
    }
};
void solve(){
    int n,m;
    cin>>n>>m;
    int q[n*m+1]={0};
    vector<node> mp(n*m+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>mp[(i-1)*m+j].v;
            mp[(i-1)*m+j].w=i+j-2;
        }
    }
    sort(mp.begin()+1,mp.end());
    int ans=0,ls=1;
    for(int i=1;i<=n*m;i++){
        //if(mp[i].v>ans) break;
        //cout<<i<<" "<<mp[i].v<<" "<<mp[i].w<<endl;
        if(q[mp[i].w]) break;
        ans=mp[i].v;
        if(q[i]==0)q[mp[i].w]++;
    }
    if(ans==0) cout<<"0\n";
    else cout<<ans+1<<"\n";
}

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



void write(int x)
{
    if(x<0)
        putchar('-'),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
    return;
}
int read()
{
    int x=0,f=1;
    char ch=nc();
    while(ch<48||ch>57)
    {
        if(ch=='-')
            f=-1;
        ch=nc();
    }
    while(ch>=48&&ch<=57)
        x=x*10+ch-48,ch=nc();
   	return x*f;
}

// ll ksm(ll a,ll b,ll mod){
//     ll ans=1;
//     a%=mod;
//     while(b>0){
//         if(b&1) ans=ans*a%mod;
//         a=a*a%mod;
//         b>>=1;
//     }
//     return ans;
// }

詳細信息

Test #1:

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

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: 39ms
memory: 3848kb

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

result:

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