Submission #928989

# Submission time Handle Problem Language Result Execution time Memory
928989 2024-02-17T11:53:47 Z Lyrically Tracks in the Snow (BOI13_tracks) C++17
0 / 100
468 ms 141912 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
void file(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}
int n,m;
char c[4005][4005];
int dis[4005][4005];
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
signed main(){
	cin>>n>>m;
	rep1(i,n)scanf("%s",c[i]+1);
	memset(dis,-1,sizeof(dis));
	dis[1][1]=0;
	queue<array<int,2>> q;q.push({1,1});
	while(!q.empty()){
		array<int,2> x=q.front();q.pop();
		rep(i,4){
			int tx=x[0]+dx[i],ty=x[1]+dy[i];
			if(tx<1||ty<1||tx>n||ty>m)continue;
			if(c[tx][ty]=='.')continue;
			if(dis[tx][ty]!=-1)continue;
			dis[tx][ty]=dis[x[0]][x[1]]+(c[x[0]][x[1]]!=c[tx][ty]);
			q.push({tx,ty});
		}
	}
	cout<<dis[n][m]<<"\n";
	return 0;
}

Compilation message

tracks.cpp: In function 'void file(std::string)':
tracks.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  freopen((s+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:10:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  freopen((s+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp: In function 'int main()':
tracks.cpp:19:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  rep1(i,n)scanf("%s",c[i]+1);
      |           ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 129880 KB Output isn't correct
2 Incorrect 15 ms 127836 KB Output isn't correct
3 Incorrect 16 ms 127836 KB Output isn't correct
4 Incorrect 20 ms 130392 KB Output isn't correct
5 Incorrect 17 ms 127836 KB Output isn't correct
6 Incorrect 15 ms 127836 KB Output isn't correct
7 Incorrect 16 ms 127836 KB Output isn't correct
8 Incorrect 16 ms 127836 KB Output isn't correct
9 Incorrect 17 ms 127708 KB Output isn't correct
10 Incorrect 16 ms 127836 KB Output isn't correct
11 Incorrect 16 ms 127836 KB Output isn't correct
12 Incorrect 17 ms 127716 KB Output isn't correct
13 Incorrect 16 ms 127836 KB Output isn't correct
14 Incorrect 16 ms 127836 KB Output isn't correct
15 Incorrect 20 ms 129884 KB Output isn't correct
16 Incorrect 21 ms 130140 KB Output isn't correct
17 Incorrect 20 ms 129896 KB Output isn't correct
18 Incorrect 19 ms 129680 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 140816 KB Output isn't correct
2 Incorrect 34 ms 131932 KB Output isn't correct
3 Incorrect 114 ms 141656 KB Output isn't correct
4 Incorrect 49 ms 133972 KB Output isn't correct
5 Incorrect 108 ms 138128 KB Output isn't correct
6 Incorrect 468 ms 141652 KB Output isn't correct
7 Incorrect 18 ms 141856 KB Output isn't correct
8 Incorrect 18 ms 140892 KB Output isn't correct
9 Incorrect 18 ms 127836 KB Output isn't correct
10 Incorrect 15 ms 127832 KB Output isn't correct
11 Incorrect 19 ms 141148 KB Output isn't correct
12 Incorrect 16 ms 127836 KB Output isn't correct
13 Incorrect 35 ms 131948 KB Output isn't correct
14 Incorrect 27 ms 129884 KB Output isn't correct
15 Incorrect 28 ms 131932 KB Output isn't correct
16 Incorrect 25 ms 127836 KB Output isn't correct
17 Incorrect 64 ms 133972 KB Output isn't correct
18 Incorrect 66 ms 133968 KB Output isn't correct
19 Incorrect 48 ms 133924 KB Output isn't correct
20 Incorrect 37 ms 133976 KB Output isn't correct
21 Incorrect 72 ms 140116 KB Output isn't correct
22 Incorrect 107 ms 138064 KB Output isn't correct
23 Incorrect 110 ms 136040 KB Output isn't correct
24 Incorrect 88 ms 140116 KB Output isn't correct
25 Incorrect 405 ms 141648 KB Output isn't correct
26 Incorrect 333 ms 140220 KB Output isn't correct
27 Incorrect 422 ms 141656 KB Output isn't correct
28 Incorrect 412 ms 141912 KB Output isn't correct
29 Incorrect 443 ms 141716 KB Output isn't correct
30 Incorrect 413 ms 141252 KB Output isn't correct
31 Incorrect 246 ms 140140 KB Output isn't correct
32 Incorrect 417 ms 141688 KB Output isn't correct