# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
404047 | 2021-05-13T17:25:07 Z | Dynamic_Cast | Patkice (COCI20_patkice) | C++11 | 1000 ms | 204 KB |
//#include <bits/stdc++.h> C++11 #include <iostream> #include <vector> #include <string> #include <algorithm> #include <cmath> #include <stdio.h> #include <time.h> #include <iomanip> #include <stdlib.h> #include <list> #include <stack> #include <queue> #include <climits> #include <map> #include <set> #include<sstream> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef vector<int> vi; #define PB push_back #define MP make_pair #define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++) int main(){ ios::sync_with_stdio(0); cin.tie(0); short r,s; char sea[101][101]; scanf("%hd%hd",&r,&s); short X,Y; short x,y; for(int i=0;i<r;i++){ for(int j=0;j<s;j++){ scanf(" %c",&sea[i][j]); if (sea[i][j]=='o'){ X=i; Y=j; } } } x=X; y=Y; int coun=0; x = X; y = Y; int mi=100000; int last=-1; x = X; y = Y; if (y + 1 < s) { x = X; y = Y; y = y + 1; coun = 0; while (1) { if (sea[x][y] == 'x') { if (mi > coun) { mi = coun; last = 1; } break; } if (sea[x][y] == '.') { break; } if (sea[x][y] == '>') { y++; coun++; continue; } if (sea[x][y] == '<') { y--; coun++; continue; } if (sea[x][y] == '^') { x--; coun++; continue; } if (sea[x][y] == 'v') { x++; coun++; continue; } } } x = X; y = Y; if (x - 1 >= 0) { x = X; y = Y; x = x - 1; coun = 0; while (1) { if (sea[x][y] == 'x') { if (mi > coun) { mi = coun; last = 2; } break; } if (sea[x][y] == '.') { break; } if (sea[x][y] == '>') { y++; coun++; continue; } if (sea[x][y] == '<') { y--; coun++; continue; } if (sea[x][y] == '^') { x--; coun++; continue; } if (sea[x][y] == 'v') { x++; coun++; continue; } } } x = X; y = Y; if (x + 1 < r) { x = X; y = Y; x = x + 1; coun = 0; while (1) { if (sea[x][y] == 'x') { if(mi>coun){ mi=coun; last=3; } break; } if (sea[x][y] == '.') { break; } if (sea[x][y] == '>') { y++; coun++; continue; } if (sea[x][y] == '<') { y--; coun++; continue; } if (sea[x][y] == '^') { x--; coun++; continue; } if (sea[x][y] == 'v') { x++; coun++; continue; } } } x = X; y = Y; if (y - 1 >= 0) { x = X; y = Y; y = y - 1; coun = 0; while (1) { if (sea[x][y] == 'x') { if (mi > coun) { mi = coun; last = 4; } break; } if (sea[x][y] == '.') { break; } if (sea[x][y] == '>') { y++; coun++; continue; } if (sea[x][y] == '<') { y--; coun++; continue; } if (sea[x][y] == '^') { x--; coun++; continue; } if (sea[x][y] == 'v') { x++; coun++; continue; } } } if(last==-1){ printf(":(\n"); return 0; } if (last == 1) { printf(":)\nE\n"); return 0; } if (last == 2) { printf(":)\nN\n"); return 0; } if (last == 3) { printf(":)\nS\n"); return 0; } if (last == 4) { printf(":)\nW\n"); return 0; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1086 ms | 204 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1089 ms | 204 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |