QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#473676#6515. Path Planningmufeng12WA 0ms3736kbC++232.5kb2024-07-12 12:33:092024-07-12 12:33:09

Judging History

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

  • [2024-07-12 12:33:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3736kb
  • [2024-07-12 12:33:09]
  • 提交

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,x,y;
    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++){
            mp[(i-1)*m+j].v=read();
            mp[(i-1)*m+j].w=i+j-2;
            mp[(i-1)*m+j].x=i;
            mp[(i-1)*m+j].y=j;
            // if(mp[(i-1)*m+j].v==5||mp[(i-1)*m+j].v==2)
            // cout<<mp[(i-1)*m+j].w<<endl;
        }
    }
    sort(mp.begin()+1,mp.end());
    int ans=0,ls=1;
    int maxi=0,maxj=0;
    int bl=0;
    for(int i=1;i<=n*m;i++){
        //if(mp[i].v>ans) break;
        //cout<<i<<" "<<mp[i].v<<" "<<mp[i].w<<" "<<mp[i].x<<" "<<mp[i].y<<endl;
        if(q[mp[i].w]) {//cout<<mp[i].v<<endl;
            break;}
        for(int j=1;j<i;j++){
            if((mp[j].x>=mp[i].x&&mp[j].y>=mp[i].y)||(mp[j].x<=mp[i].x&&mp[j].y<=mp[i].y))
            {
                //cout<<j<<" "<<mp[j].v<<" "<<mp[j].w<<" "<<mp[j].x<<" "<<mp[j].y<<endl;
            }
            else 
            {
                bl=1;
                break;
            }
        }
        if(bl) 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;
// }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3736kb

input:

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

output:

3
2

result:

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