Submission #979076
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; #define pb push_back #define mp make_pair #define fi first #define se second #define N 100000 #define MOD 1000000007 #define INF 1000000000 int main() { int n, m; cin >> n >> m; string a[8]; for(int i = 0; i < n; i++){ cin >> a[i]; } queue<pii> q; q.push(mp(0, 0)); map<pii, int> used; while(!q.empty()){ pii cur = q.front(); q.pop(); pii turn1 = cur; turn1.first++; used[cur] = 1; pii turn2 = cur; turn2.second++; if(cur.first == n - 1 && cur.second == m - 1){ break; } pii turn3 = cur; turn3.first--; pii turn4 = cur; turn4.second--; if(turn3.first >= 0 && a[turn3.first][turn3.second] == '#' && !used[turn3] || turn4.second >= 0 && a[turn4.first][turn4.second] == '#' && !used[turn4]){ cout << "Impossible"; return 0; } if(!(turn1.first < n && a[turn1.first][turn1.second] == '#' && turn2.second < m && a[turn2.first][turn2.second] == '#')){ if(turn1.first < n && a[turn1.first][turn1.second] == '#'){ q.push(turn1); used[turn1] = true; } else if(turn2.second < m && a[turn2.first][turn2.second] == '#'){ q.push(turn2); used[turn2] = true; } else{ cout << "Impossible"; return 0; } } else{ cout << "Impossible"; return 0; } } cout << "Possible"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Shik and Stone |
User | toxzi |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2270 Byte |
Status | WA |
Exec Time | 140 ms |
Memory | 764 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 200 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt, example2.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, example0.txt, example1.txt, example2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 140 ms | 764 KB |
001.txt | AC | 3 ms | 256 KB |
002.txt | AC | 3 ms | 256 KB |
003.txt | AC | 3 ms | 256 KB |
004.txt | WA | 3 ms | 256 KB |
005.txt | AC | 3 ms | 256 KB |
006.txt | AC | 3 ms | 256 KB |
007.txt | AC | 3 ms | 256 KB |
008.txt | AC | 3 ms | 256 KB |
009.txt | AC | 3 ms | 256 KB |
010.txt | AC | 3 ms | 256 KB |
011.txt | AC | 3 ms | 256 KB |
012.txt | AC | 3 ms | 256 KB |
013.txt | AC | 3 ms | 256 KB |
014.txt | AC | 3 ms | 256 KB |
015.txt | AC | 3 ms | 384 KB |
016.txt | AC | 3 ms | 256 KB |
017.txt | AC | 3 ms | 256 KB |
018.txt | AC | 2 ms | 256 KB |
example0.txt | AC | 3 ms | 256 KB |
example1.txt | AC | 3 ms | 256 KB |
example2.txt | AC | 3 ms | 256 KB |