Submission #97121

# Submission time Handle Problem Language Result Execution time Memory
97121 2019-02-14T02:24:44 Z ahgus89 None (JOI16_skating) C++14
0 / 100
3000 ms 1148 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, 16);
    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 1229 ms 1052 KB Output is correct
2 Correct 248 ms 960 KB Output is correct
3 Correct 5 ms 996 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 3 ms 648 KB Output is correct
6 Execution timed out 3049 ms 1148 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1229 ms 1052 KB Output is correct
2 Correct 248 ms 960 KB Output is correct
3 Correct 5 ms 996 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 3 ms 648 KB Output is correct
6 Execution timed out 3049 ms 1148 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1229 ms 1052 KB Output is correct
2 Correct 248 ms 960 KB Output is correct
3 Correct 5 ms 996 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 3 ms 648 KB Output is correct
6 Execution timed out 3049 ms 1148 KB Time limit exceeded
7 Halted 0 ms 0 KB -