QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#109873#6515. Path Planningzzzyzzz#WA 2ms3484kbC++171.4kb2023-05-30 20:52:242023-05-30 20:52:29

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-30 20:52:29]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3484kb
  • [2023-05-30 20:52:24]
  • 提交

answer

#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;
const int N=1e6+7;
typedef long long ll;
typedef pair<int,int> PII;

inline ll read() {
	ll c=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-') f=-f;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		c=c*10+ch-'0';
		ch=getchar();
	}
	return c*f;
}


int n,m,k;
vector<vector<int> > w;
PII vis[N];

bool check(int &res,set<pair<pair<int,int>,pair<int,int> > > &st) {
	int x=vis[res].fi,y=vis[res].se;
	pair<pair<int,int>,pair<int,int> > temp={{x,y},{-1,-1}};
	auto it=st.upper_bound(temp);
	if(it==st.end()) return false;
	
	int x1=it->se.fi,y1=it->se.se;
	int x2=it->fi.fi,y2=it->fi.se;
	if(x>=x1&&x<=x2&&y>=y1&&y<=y2) {
		st.erase(it);
		st.insert({{x,y},{x1,y1}});
		st.insert({{x2,y2},{x,y}});
		res++;
		return true;
	}else return false;
}

void solve() {
	w.clear();
	n=read(),m=read();	
	
	vector<int> p;
	w.push_back(p);
	for(int i=1;i<=n;i++) {
		vector<int> s;
		s.push_back(0);
		for(int j=1;j<=m;j++) {
			int c=read();
			s.push_back(c);
		}
		w.push_back(s);
	}
	
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			vis[w[i][j]]={i,j};
		}
	}
	
	int res=0;
	set<pair<pair<int,int>,pair<int,int> > > st;
	st.insert({{n,m},{1,1}});
	while(check(res,st)) ;
	printf("%d\n",res);
}

int main() {
	int T;
	n=read();
	while(T--) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3484kb

input:

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

output:


result:

wrong answer Answer contains longer sequence [length = 2], but output contains 0 elements