Submission #1355424


Source Code Expand

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int H,W;
	cin >> H >> W;
	vector< vector<bool> > fld(H,vector<bool>(W));
	for(int h=0;h<H;++h){
		string str;
		cin >> str;
		for(int w=0;w<W;++w){
			if( str[w] =='#' ){
				fld[h][w] = true;
			}
		}
	}
	if( fld[0][0] == false ){
		cout << "Impossible" << endl;return;
	}
	for(int h=0;h<H;++h){
		for(int w=0;w<W;++w){
			if( fld[h][w] ){
				int res = 0;
				if( h+1<H ){res += fld[h+1][w];}
				if( w+1<W ){res += fld[h][w+1];}
				if( res != 1 ){
					if( h==H-1 && w==W-1 ) continue;//右下は停止
					cout << "Impossible" << endl;
					return;
				}
			}
		}
	}
	cout << "Possible" << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()

Submission Info

Submission Time
Task A - Shik and Stone
User akarin55
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1830 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
AC × 3
AC × 20
WA × 2
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 WA 1 ms 256 KB
002.txt AC 1 ms 256 KB
003.txt AC 1 ms 256 KB
004.txt WA 1 ms 256 KB
005.txt AC 1 ms 256 KB
006.txt AC 1 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 AC 1 ms 256 KB
example2.txt AC 1 ms 256 KB