Submission #1694447
Source Code Expand
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
const int MAX_N = 100005;
const int dx[2]={1,0};
const int dy[2]={0,1};
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int h,w;
cin >> h >> w;
vector<string> s(h);
rep(i,h){
cin >> s[i];
}
if(s[0][0] == '.'){
cout << "Impossible\n";
}else{
s[0][0] = '.';
int ni=0,nj=0;
bool flag = true;
while(1){
if(ni == h-1 && nj == w-1){
break;
}
rep(i,2){
int nx=ni+dx[i],ny=nj+dy[i];
if(0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] == '#'){
ni = nx,nj = ny;
s[ni][nj] = '.';
flag = false;
break;
}
}
if(flag){
cout << "Impossible\n";
return 0;
}
}
rep(i,h){
rep(j,w){
if(s[i][j] != '.'){
cout << "Impossible\n";
return 0;
}
}
}
cout << "Possible\n";
}
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Shik and Stone |
User |
kopricky |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2275 Byte |
Status |
TLE |
Exec Time |
2103 ms |
Memory |
256 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 |
1 ms |
256 KB |
001.txt |
AC |
1 ms |
256 KB |
002.txt |
TLE |
2103 ms |
256 KB |
003.txt |
AC |
1 ms |
256 KB |
004.txt |
AC |
1 ms |
256 KB |
005.txt |
AC |
1 ms |
256 KB |
006.txt |
TLE |
2103 ms |
256 KB |
007.txt |
AC |
1 ms |
256 KB |
008.txt |
AC |
1 ms |
256 KB |
009.txt |
AC |
1 ms |
256 KB |
010.txt |
AC |
1 ms |
256 KB |
011.txt |
AC |
1 ms |
256 KB |
012.txt |
AC |
1 ms |
256 KB |
013.txt |
AC |
1 ms |
256 KB |
014.txt |
AC |
1 ms |
256 KB |
015.txt |
AC |
1 ms |
256 KB |
016.txt |
AC |
1 ms |
256 KB |
017.txt |
AC |
1 ms |
256 KB |
018.txt |
AC |
1 ms |
256 KB |
example0.txt |
AC |
1 ms |
256 KB |
example1.txt |
TLE |
2103 ms |
256 KB |
example2.txt |
AC |
1 ms |
256 KB |