QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#617812 | #8236. Snake Move | ukuk | Compile Error | / | / | C++20 | 1.4kb | 2024-10-06 17:13:39 | 2024-10-06 17:13:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
const int INF=1e9+7;
const int N = 3005;
int n,m,k;
string s[N];
int a[N][N];
int dis[N][N];
int xx[4]={-1,0,1,0},yy[4]={0,1,0,-1};
void bfs(int sx,int sy){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
dis[i][j]=INF;
}
}
dis[sx][sy]=0;
queue<PII>q;
q.push({sx,sy});
while(!q.empty()){
int x=q.front().first,y=q.front().second;
q.pop();
for(int i=0;i<4;i++){
int tx=x+xx[i],ty=y+yy[i];
if(tx>n||tx<1||ty>m||ty<1||s[tx][ty]=='#')continue;
int w=dis[x][y];
int lv=max(a[tx][ty]-dis[x][y],0ll);
if(dis[tx][ty]>w+lv+1){
dis[tx][ty]=w+lv+1;
q.push({tx,ty});
}
}
}
}
void solve() {
cin>>n>>m>>k;
int sx,sy;
for(int i=1;i<=k;i++){
int x,y;cin>>x>>y;
a[x][y]=k-i;
if(i==1)sx=x,sy=y;
}
for(int i=1;i<=n;i++){
cin>>s[i];
s[i]=' '+s[i];
}
bfs(sx,sy);
// for(int i=1;i<=n;i++){
// for(int j=1;j<=m;j++){
// if(dis[i][j]==INF)cout<<"x ";
// else cout<<dis[i][j]<<' ';
// }
// cout<<'\n';
// }
// cout<<'\n';
unsigned long long ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(dis[i][j]==INF)continue;
ans+=(unsigned long long)dis[i][j]*dis[i][j];
}
}
cout<<ans<<'\n';
}
signed main() {
int t=1; //cin >> t;
while (t--) solve();
return 0;
}
Details
answer.code:2:1: error: extended character is not valid in an identifier 2 | | ^ answer.code:4:1: error: extended character is not valid in an identifier 4 | | ^ answer.code:9:1: error: extended character is not valid in an identifier 9 | | ^ answer.code:15:1: error: extended character is not valid in an identifier 15 | | ^ answer.code:70:1: error: extended character is not valid in an identifier 70 | | ^ answer.code:2:1: error: ‘ ’ does not name a type 2 | | ^ answer.code:4:1: error: ‘ ’ does not name a type 4 | | ^ answer.code:9:1: error: ‘ ’ does not name a type 9 | | ^ answer.code:11:1: error: ‘string’ does not name a type; did you mean ‘stdin’? 11 | string s[N]; | ^~~~~~ | stdin answer.code:15:1: error: ‘ ’ does not name a type 15 | | ^ answer.code: In function ‘void solve()’: answer.code:41:9: error: ‘cin’ was not declared in this scope; did you mean ‘std::cin’? 41 | cin>>n>>m>>k; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:146, from answer.code:1: /usr/include/c++/13/iostream:62:18: note: ‘std::cin’ declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ answer.code:41:14: error: ‘n’ was not declared in this scope 41 | cin>>n>>m>>k; | ^ answer.code:41:17: error: ‘m’ was not declared in this scope; did you mean ‘tm’? 41 | cin>>n>>m>>k; | ^ | tm answer.code:41:20: error: ‘k’ was not declared in this scope 41 | cin>>n>>m>>k; | ^ answer.code:49:22: error: ‘s’ was not declared in this scope 49 | cin>>s[i]; | ^ answer.code:52:9: error: ‘bfs’ was not declared in this scope; did you mean ‘ffs’? 52 | bfs(sx,sy); | ^~~ | ffs answer.code:64:39: error: ‘INF’ was not declared in this scope 64 | if(dis[i][j]==INF)continue; | ^~~ answer.code:68:9: error: ‘cout’ was not declared in this scope; did you mean ‘std::cout’? 68 | cout<<ans<<'\n'; | ^~~~ | std::cout /usr/include/c++/13/iostream:63:18: note: ‘std::cout’ declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ answer.code: At global scope: answer.code:70:1: error: ‘ ’ does not name a type 70 | | ^