# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
480914 |
2021-10-18T17:51:26 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;
dist[x][y] = 1;
dist[tx][ty] = 1e9+1;
while(true){
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;
}
if(dist[tx][ty] != 1e9+1){
cout<<":)"<<'\n';
cout<<c[i]<<'\n';
return 0;
}
if(dist[tx][ty] < ans){
ans = dist[tx][ty];
f = c[i];
}
else if(dist[tx][ty] == ans)f = min(c[i],f);
}
if(ans == 1e9)cout<<":("<<'\n';
else{
cout<<":)"<<'\n';
cout<<f<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 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 |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Incorrect |
0 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 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |