# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1046619 |
2024-08-06T18:19:15 Z |
1L1YA |
Maze (JOI23_ho_t3) |
C++17 |
|
0 ms |
0 KB |
//1L1YA
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3,unrool-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define Pb push_back
#define F first
#define S second
#define endl '\n'
#define sep ' '
#define all(x) x.begin(),x.end()
#define al(x,n) x+1,x+n+1
#define SZ(x) ((int)x.size())
#define lc (id<<1)
#define rc (lc|1)
#define mid (l+r>>1)
#define dokme(x) cout << x << endl, exit(0)
#define sik(x) cout << x << endl;continue;
#define FastIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll oo=1e18;
const int mod=1e9+7;
const int inf=1e9+111;
const int N=2e5+11;
const int lg=23;
int n,m,k,xs,ys,xt,yt,x[4]={1,-1,0,0},y[4]={0,0,1,-1},d[N][N];
string s[N];
void bfs(){
deque<pii> dq;
dq.Pb({xs,ys});
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
d[i][j]=inf;
d[xs][ys]=0;
while(!dq.empty()){
int p=dq.front().F,q=dq.front().S;dq.pop_front();
for(int i=0;i<4;i++)
if(p+x[i] && p+x[i]<=n && q+y[i] && q+y[i]<=m && s[p+x[i]][q+y[i]]=='.' && d[p][q]<d[p+x[i]][q+y[i]]){
d[p+x[i]][q+y[i]]=d[p][q];
dq.push_front({p+x[i],q+y[i]});
}
for(int X=1;X<=n;X++)
for(int Y=1;Y<=m;Y++)
if(abs(X-p)<=k && abs(Y-q)<=k && d[p][q]+1<d[X][Y]){
d[X][Y]=d[p][q]+1;
dq.Pb({X,Y});
}
}
}
int main(){
FastIO
cin >> n >> m >> k >> xs >> ys >> xt >> yt;
for(int i=1;i<=n;i++){
cin >> s[i];
s[i]='#'+s[i];
}
bfs();
cout << d[xt][yt] << endl;
return 0;
}
Compilation message
/tmp/ccDQjKHl.o: in function `bfs()':
Main.cpp:(.text+0x21d): relocation truncated to fit: R_X86_64_PC32 against symbol `xs' defined in .bss section in /tmp/ccDQjKHl.o
Main.cpp:(.text+0x22c): relocation truncated to fit: R_X86_64_PC32 against symbol `ys' defined in .bss section in /tmp/ccDQjKHl.o
Main.cpp:(.text+0x262): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccDQjKHl.o
Main.cpp:(.text+0x26f): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccDQjKHl.o
Main.cpp:(.text+0x2ce): relocation truncated to fit: R_X86_64_PC32 against symbol `xs' defined in .bss section in /tmp/ccDQjKHl.o
Main.cpp:(.text+0x2d5): relocation truncated to fit: R_X86_64_PC32 against symbol `ys' defined in .bss section in /tmp/ccDQjKHl.o
Main.cpp:(.text+0x337): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccDQjKHl.o
Main.cpp:(.text+0x36f): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccDQjKHl.o
Main.cpp:(.text+0x3e2): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccDQjKHl.o
Main.cpp:(.text+0x412): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccDQjKHl.o
Main.cpp:(.text+0x451): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status