Submission #846406

#TimeUsernameProblemLanguageResultExecution timeMemory
846406vjudge1ČVENK (COI15_cvenk)C++17
0 / 100
807 ms524288 KiB
#include <bits/stdc++.h>
typedef long long ll;
#define yem(re) (1ll<<((ll)(re)))
#define endl '\n'
#define pb push_back
#define int long long
#define mid ((left+right)/2)

using namespace std;

int n;
queue<pair<pair<int,int>,int>>q;
map<int,map<int,bool>>vis;

int32_t main(){
	cin>>n;
	pair<int,int>bas,tar;
	cin>>bas.first>>bas.second>>tar.first>>tar.second;
	q.push({bas,0});
	while(q.size()){
		int x=q.front().first.first,y=q.front().first.second,total=q.front().second;
		q.pop();
		if(vis[x][y])continue;
		if(x&y!=0)continue;
		if(x<0||y<0)continue;
		if(x>=1e9||y>=1e9)continue;
		if(x==tar.first&&y==tar.second){cout<<total;return 0;}
		q.push({{x+1,y},total+1});
		q.push({{x-1,y},total+1});
		q.push({{x,y-1},total+1});
		q.push({{x,y+1},total+1});
	}
	return 0;
}

Compilation message (stderr)

cvenk.cpp: In function 'int32_t main()':
cvenk.cpp:24:9: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   24 |   if(x&y!=0)continue;
      |        ~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...