# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
480911 |
2021-10-18T17:43:01 Z |
CSQ31 |
Patkice (COCI20_patkice) |
C++17 |
|
1 ms |
332 KB |
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
char g[200][200];
int dist[200][200];
char c[4] = {'E','N','S','W'};
int dy[4] = {1,0,0,-1};
int dx[4] = {0,-1,1,0};
int r,s;
bool check(int x,int y){
return x>=0 && x<r && y>=0 && y<s;
}
int main()
{
cin>>r>>s;
int sx,sy,tx,ty;
sx = sy = tx = ty = 0;
for(int i=0;i<r;i++){
for(int j=0;j<s;j++){
cin>>g[i][j];
if(g[i][j] == 'o'){
sx = i;
sy = j;
}
if(g[i][j] == 'x'){
tx = i;
ty = j;
}
}
}
int ans = 1e9;
char f = 'Z';
for(int i=0;i<4;i++){
int x = sx+dx[i];
int y = sy+dy[i];
if(!check(x,y))continue;
for(int i=0;i<r;i++)
for(int j=0;j<s;j++)dist[i][j] = -1;
dist[x][y] = 1;
dist[tx][ty] = -1;
while(true){
//cout<<x<<" "<<y<<'\n';
int d = dist[x][y];
if(g[x][y] == 'o' || g[x][y] == '.' || g[x][y] == 'x')break;
if(g[x][y] == '^')x--;
else if(g[x][y] == 'v')x++;
else if(g[x][y] == '>')y++;
else y--;
dist[x][y] = d+1;
}
//cout<<dist[tx][ty]<<" "<<ans<<'\n';
if(dist[tx][ty] == -1)continue;
if(dist[tx][ty] < ans){
ans = dist[tx][ty];
f = c[i];
}
}
if(ans == 1e9)cout<<":(";
else{
cout<<":)"<<'\n';
cout<<f<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
296 KB |
Output is correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
300 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |