Submission #1444552
Source Code Expand
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
char t=getchar();
bool neg=false;
x=0;
for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
if(t=='-')neg=true,t=getchar();
for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
if(x<0)putchar('-'),x=-x;
short a[20]= {},sz=0;
while(x>0)a[sz++]=x%10,x/=10;
if(sz==0)putchar('0');
for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);
int n,m;
bool vis[10][10];
char s[10][10];
void dfs(int x,int y)
{
vis[x][y]=1;
if(s[x][y+1]=='#'&&!vis[x][y+1])
dfs(x,y+1);
else if(s[x+1][y]=='#'&&!vis[x+1][y])
dfs(x+1,y);
}
int main()
{
get2(n,m);
for(int i=1;i<=n;i++)
scanf("%s",s[i]+1);
dfs(1,1);
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(s[i][j]=='#'&&!vis[i][j])
{
puts("Impossible");
return 0;
}
puts("Possible");
return 0;
}
Submission Info
Submission Time
2017-07-23 15:28:41+0900
Task
A - Shik and Stone
User
OhWeOnFire
Language
C++14 (GCC 5.4.1)
Score
200
Code Size
1618 Byte
Status
AC
Exec Time
1 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:66:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s",s[i]+1);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
200 / 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
AC
1 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
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