QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#632763#7733. Cool, It’s Yesterday Four Times MoreYurily#Compile Error//C++202.6kb2024-10-12 13:55:052024-10-12 13:55:06

Judging History

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

  • [2024-10-12 13:55:06]
  • 评测
  • [2024-10-12 13:55:05]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#define _fi first
#define _se second
using namespace std;

const int N = 1e3;

	int n, m, a[N + 3][N + 3];
	int cnt;
	vector<pair<int, int> >blk[N * N + 3];	/ock
	
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
	
bool lim(int x, int y){
	if(x < 1 || x > n || y < 1 || y > m)
		return false;
	return true;
}

void bfs(int sx, int sy){
	queue<pair<int, int> >que;
	que.push(make_pair(sx, sy));
	
	int ux, uy, vx, vy;
	while(!que.empty()){
		ux = que.front().first;
		uy = que.front().second;
		que.pop();
		
//		printf("u:(%d,%d)\n", ux, uy);
		
		for(int t = 0; t < 4; t++){
			vx = ux + dx[t];
			vy = uy + dy[t];
			
			if(!lim(vx, vy) || a[vx][vy] != 0)
				continue;
				
//			printf("v(%d,%d)\n", vx, vy);
			
			a[vx][vy] = a[ux][uy];
			blk[a[ux][uy]].emplace_back(vx, vy);
			que.push(make_pair(vx, vy));
			
		}
	}
}

	bool cov[N * N + 3];				//covered

void sol(){
	scanf("%d%d\n", &n, &m);
	for(int i = 1; i <= n; i++){
		char ch;
		for(int j = 1; j <= m; j++){
			ch = getchar();
			if(ch == '.')
				a[i][j] = 0;
			else 
				a[i][j] = -1;
		}
		getchar();
	}
	
	cnt = 0;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(a[i][j] == 0){
				cnt++;
				blk[cnt].clear();
				
				a[i][j] = cnt;
				blk[cnt].emplace_back(i, j);
				bfs(i, j);
			}
			
//	printf("%d %d\n", n, m);
//	for(int i = 1; i <= n; i++){
//		for(int j = 1; j <= m ;j++)
//			printf("%3d", a[i][j]);
//		printf("\n");
//	}
	
	memset(cov, 0, (cnt + 1) * sizeof(bool));
	
	for(int px = 1 - n; px <= n - 1; px++){
		for(int py = 1 - m; py <= m - 1; py++){
			if(px == 0 && py == 0)
				continue;
				
			for(int i = 1; i <= cnt; i++)
				if(!cov[i]){
					int col = 0;
					for(int j = 0, nx, ny; j < blk[i].size() && col != -1; j++){
						nx = blk[i][j]._fi - px;
						ny = blk[i][j]._se - py;
						if(!lim(nx, ny) || a[nx][ny] == -1)
							col = -1;
						else{
							if(col == 0)
								col = a[nx][ny];
							else {
								if(col != a[nx][ny])
									col = -1;
							}
						}
									
					}
					
					if(col > 0){
//						printf("block%d covered at p(%d,%d)\n", i, px, py);
						cov[i] = true;
					}
				}
			
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= cnt; i++)
		if(!cov[i])
			ans += blk[i].size();
	
	printf("%d\n", ans);
	
//	printf("\n");

}

int main(){
//	freopen("data.in", "r", stdin);
//	freopen("data.out", "w", stdout);

	int T;
	scanf("%d\n", &T);
	while(T--)
		sol();

	return 0;

}

Details

answer.code:16:49: error: expected unqualified-id before ‘/’ token
   16 |         vector<pair<int, int> >blk[N * N + 3];  /ock
      |                                                 ^
answer.code: In function ‘void bfs(int, int)’:
answer.code:40:35: error: ‘dx’ was not declared in this scope; did you mean ‘vx’?
   40 |                         vx = ux + dx[t];
      |                                   ^~
      |                                   vx
answer.code: In function ‘void sol()’:
answer.code:59:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   59 |         scanf("%d%d\n", &n, &m);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:142:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  142 |         scanf("%d\n", &T);
      |         ~~~~~^~~~~~~~~~~~