QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#88111 | #3251. 数正方体 | DoubleQing | RE | 0ms | 0kb | C++11 | 1.8kb | 2023-03-15 10:43:41 | 2023-03-15 10:43:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
#define x first
#define y second
const int N=100,M=2*N,mod=1e9+7;
char mp[N][N];
int n,m;
int cnt;
bool st[N][N];
int dx[]={0,2,0},dy[]={4,-2,-4};
int cx[]={0,0,1,-1},cy[]={1,-1,0,0};
int last,res;
void bfs(int sx,int sy)
{
queue<PII> q;
q.push({sx,sy});
st[sx][sy]=1;
while(q.size())
{
PII t=q.front();
q.pop();
int x=t.x,y=t.y;
bool f=1;
for(int i=0;i<3;i++)
{
int xx=x+dx[i],yy=y+dy[i];
if(xx<1||xx>n||yy<1||yy>m||mp[xx][yy]!='+'||st[xx][yy])
continue;
st[xx][yy]=1;
q.push({xx,yy});
if(mp[xx][yy-1]=='-'&&mp[xx+1][yy-1]=='/')
cnt++;
}
}
res=last=cnt;
}
void bfs1(int sx,int sy)
{
cnt=0;
queue<PII> q;
q.push({sx,sy});
st[sx][sy]=1;
while(q.size())
{
PII t=q.front();
q.pop();
int x=t.x,y=t.y;
for(int i=0;i<3;i++)
{
bool f=1;
int xx=x+dx[i],yy=y+dy[i];
if(xx<1||xx>n||yy<1||yy>m||mp[xx][yy]!='+'||st[xx][yy])
continue;
st[xx][yy]=1;
q.push({xx,yy});
for(int i=0;i<4;i++)
if(mp[x+cx[i]][y+cy[i]]=='.')
{
f=0;
break;
}
if(f&&mp[xx-1][yy]!='|'&&!(mp[xx+1][yy]!='|'))
cnt++;
}
}
last+=cnt;
res+=last;
}
void solve()
{
scanf("%d %d",&n,&m);
getchar();
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
mp[i][j]=getchar();
getchar();
}
for(int i=1;i<=n;i++)
{
bool f=0;
for(int j=1;j<=m;j++)
if(mp[i][j]=='+')
{
bfs(i,j),f=1;
break;
}
if(f)
break;
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(mp[i][j]=='+'&&!st[i][j])
bfs1(i,j);
cout<<res-last<<endl;
return;
}
signed main()
{
// ios::sync_with_stdio(false);
// cin.tie(0),cout.tie(0);
int T=1;
//cin>>T;
while(T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
371 259 ......................................................................+---+---+.................................................................................................................................................................................... ...................................