QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#240409#3251. 数正方体Cofe_Milk#AC ✓1ms4072kbC++172.2kb2023-11-05 15:15:592023-11-05 15:16:00

Judging History

你现在查看的是最新测评结果

  • [2023-11-05 15:16:00]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4072kb
  • [2023-11-05 15:15:59]
  • 提交

answer

//#include<bitsdc++.h>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <set>
#include <list>
#include <map>
#include <cstdlib>
#include <bitset>
#include <limits.h>
using namespace std;
//#define int long long
//#define double long double
#define fi first 
#define se second
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define FILL(a,b) (memset(a,b,sizeof(a)))
#define ios std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define endl '\n'
#define rep(i,j,k,l) for(int i=j;i<=k;i+=l)
#define per(i,j,k,l) for(int i=j;i>=k;i-=l)
#define Rep(i,j,k,l) for(int i=j;i<k;i+=l)
#define Per(i,j,k,l) for(int i=j;i>k;i-=l)
#define ls u<<1
#define rs u<<1|1
const int N=5010,mod=998244353;
const double eps=1e-8;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef long long ll;
int n,m;
string a[N];
bool check(int x,int y)
{
	for(int i=1;i<=3;i++) 
		if(a[x][y+i]!='-'||a[x+3][y+i]!='-') return false;
	for(int i=1;i<=2;i++)
		if(a[x+i][y]!='|'||a[x+i][y+4]!='|') return false;
	return a[x][y+4]=='+'&&a[x+3][y]=='+'&&a[x+3][y+4]=='+';
}
int dfs(int x,int y)
{
	if(x<1||x>n||y<1||y>m) return 0;
	int sum=0;
	while(y+4<=m&&a[x][y+4]=='+'&&a[x][y+1]=='-'&&a[x][y+2]=='-'&&a[x][y+3]=='-') y+=4;
	if(x-2>=1&&y+2<=m&&a[x-2][y+2]=='+'&&a[x-1][y+1]=='/') sum+=dfs(x-2,y+2)+1;
	return sum;
}
int calc(int x,int y)
{
	if(check(x,y)) return dfs(x,y);	
	else return 0;
}
void solve()
{
	cin>>n>>m;
	getline(cin,a[0]);
	for(int i=1;i<=n;i++)
	{
		getline(cin,a[i]);
		a[i]=" "+a[i];
	}
	//	for(int i=1;i<=n;i++)
	//	{
	//		for(int j=1;j<=m;j++) cout<<a[i][j];
	//		cout<<endl;
	//	}
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(a[i][j]=='+') ans+=calc(i,j);
	cout<<ans;
}
signed main()
{
	ios
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4068kb

input:

371 259
......................................................................+---+---+....................................................................................................................................................................................
...................................

output:

84826

result:

ok single line: '84826'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3900kb

input:

398 301
....................................................................................................+---+..............................................................................................................................................................................................

output:

128658

result:

ok single line: '128658'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3896kb

input:

401 301
....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---...

output:

250000

result:

ok single line: '250000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3880kb

input:

401 301
....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................................................

output:

144484

result:

ok single line: '144484'

Test #5:

score: 0
Accepted
time: 1ms
memory: 4072kb

input:

395 235
..............................................................................................+---+---+....................................................................................................................................
...........................................................

output:

82548

result:

ok single line: '82548'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

401 301
....................................................................................................+---+---+---+......................................................................................................................................................................................

output:

125068

result:

ok single line: '125068'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

367 259
..................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+................................................................................................................................
...................................

output:

80503

result:

ok single line: '80503'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3880kb

input:

397 229
................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+....................................................................
.................................................................

output:

82439

result:

ok single line: '82439'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3816kb

input:

401 301
....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................

output:

127263

result:

ok single line: '127263'

Test #10:

score: 0
Accepted
time: 1ms
memory: 4036kb

input:

398 301
....................................................................................................+---+..............................................................................................................................................................................................

output:

151454

result:

ok single line: '151454'

Test #11:

score: 0
Accepted
time: 1ms
memory: 3816kb

input:

398 301
....................................................................................................+---+---+---+---+---+---+---+---+---+---+..........................................................................................................................................................

output:

182883

result:

ok single line: '182883'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

401 301
....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................................................

output:

209274

result:

ok single line: '209274'