Submission #1191643

#TimeUsernameProblemLanguageResultExecution timeMemory
1191643SmuggingSpunPatkice (COCI20_patkice)C++20
30 / 50
1 ms328 KiB
#include<bits/stdc++.h> #define taskname "A" using namespace std; const int lim = 105; const int INF = 1e9; char d = '#', a[lim][lim]; int n, m, min_time = INF; bitset<lim>vis[lim]; void move(int i, int j, int t, const char ans){ if(a[i][j] == 'x'){ min_time = t; d = ans; return; } if(vis[i].test(j) || a[i][j] == '.' || t > min_time - 2){ return; } vis[i].set(j); if(a[i][j] == '^'){ move(i - 1, j, t + 1, ans); } else if(a[i][j] == 'v'){ move(i + 1, j, t + 1, ans); } else if(a[i][j] == '<'){ move(i, j - 1, t + 1, ans); } else{ move(i, j + 1, t + 1, ans); } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } cin >> n >> m; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin >> a[i][j]; } } for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(a[i][j] == 'o'){ for(int k = 1; k <= n; k++){ vis[k].reset(); } move(i, j + 1, 0, 'E'); move(i - 1, j, 0, 'N'); move(i + 1, j, 0, 'S'); move(i, j - 1, 0, 'W'); if(d == '#'){ return cout << ":(", 0; } return cout << ":)\n" << d, 0; } } } }

Compilation message (stderr)

patkice.cpp: In function 'int main()':
patkice.cpp:35:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...