# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
97119 |
2019-02-14T02:23:10 Z |
ahgus89 |
None (JOI16_skating) |
C++14 |
|
1511 ms |
1600 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int n, m, k, ans, arr[101010], mod=1e9+7;
vector<string> board(1010);
int sx, sy, ex, ey, dx[4]= {0, 0, 1, -1}, dy[4]= {1, -1, 0, 0};
void input()
{
int i, j;
cin>>n>>m;
for(i=0; i<n; i++)
cin>>board[i];
cin>>sx>>sy>>ex>>ey;
sx--;sy--;ex--;ey--;
}
bool valid(int x, int y)
{
return 0<=x&&x<n&&0<=y&&y<m;
}
int calc(vector<string> v, int x, int y, int d)
{
if(x==ex&&y==ey)
return 0;
if(d==0) return 1e9;
//cout<<"Calc at "<<x<<' '<<y<<'\n';
int i, j, ret=1e9, tx=x, ty=y;
v[tx][ty]='#';
for(i=0; i<4; i++)
{
x=tx;y=ty;
while(v[x+dx[i]][y+dy[i]]=='.')
{
x+=dx[i];
y+=dy[i];
}
if(x==tx&y==ty)
continue;
ret=min(ret, 1+calc(v, x, y, d-1));
}
//cout<<"Calc("<<x<<", "<<y<<") = "<<ret<<'\n';
return ret;
}
int main()
{
//freopen("input.txt", "r", stdin);
ios_base::sync_with_stdio(false);
cin.tie(0);
input();
int i, j, temp=0;
ans=calc(board, sx, sy, 11);
if(ans==1e9) cout<<"-1";
else cout<<ans;
}
Compilation message
skating.cpp: In function 'void input()':
skating.cpp:10:12: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
skating.cpp: In function 'int calc(std::vector<std::__cxx11::basic_string<char> >, int, int, int)':
skating.cpp:37:13: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
if(x==tx&y==ty)
~^~~~
skating.cpp:27:12: warning: unused variable 'j' [-Wunused-variable]
int i, j, ret=1e9, tx=x, ty=y;
^
skating.cpp: In function 'int main()':
skating.cpp:50:9: warning: unused variable 'i' [-Wunused-variable]
int i, j, temp=0;
^
skating.cpp:50:12: warning: unused variable 'j' [-Wunused-variable]
int i, j, temp=0;
^
skating.cpp:50:15: warning: unused variable 'temp' [-Wunused-variable]
int i, j, temp=0;
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
1052 KB |
Output is correct |
2 |
Correct |
19 ms |
956 KB |
Output is correct |
3 |
Correct |
4 ms |
832 KB |
Output is correct |
4 |
Correct |
3 ms |
640 KB |
Output is correct |
5 |
Correct |
4 ms |
648 KB |
Output is correct |
6 |
Correct |
109 ms |
804 KB |
Output is correct |
7 |
Correct |
35 ms |
832 KB |
Output is correct |
8 |
Correct |
36 ms |
800 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
10 ms |
824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
1052 KB |
Output is correct |
2 |
Correct |
19 ms |
956 KB |
Output is correct |
3 |
Correct |
4 ms |
832 KB |
Output is correct |
4 |
Correct |
3 ms |
640 KB |
Output is correct |
5 |
Correct |
4 ms |
648 KB |
Output is correct |
6 |
Correct |
109 ms |
804 KB |
Output is correct |
7 |
Correct |
35 ms |
832 KB |
Output is correct |
8 |
Correct |
36 ms |
800 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
10 ms |
824 KB |
Output is correct |
11 |
Incorrect |
1511 ms |
1600 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
1052 KB |
Output is correct |
2 |
Correct |
19 ms |
956 KB |
Output is correct |
3 |
Correct |
4 ms |
832 KB |
Output is correct |
4 |
Correct |
3 ms |
640 KB |
Output is correct |
5 |
Correct |
4 ms |
648 KB |
Output is correct |
6 |
Correct |
109 ms |
804 KB |
Output is correct |
7 |
Correct |
35 ms |
832 KB |
Output is correct |
8 |
Correct |
36 ms |
800 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
10 ms |
824 KB |
Output is correct |
11 |
Incorrect |
1511 ms |
1600 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |