QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#865297#8118. PahuljiceUnforgettablepl#Compile Error//C++141.6kb2025-01-21 16:33:172025-01-21 16:33:19

Judging History

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

  • [2025-01-21 16:33:19]
  • 评测
  • [2025-01-21 16:33:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long


int32_t main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	vector grid(n+1,vector<char>(m+1));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin >> grid[i][j];
		}
	}
	int ma = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(grid[i][j]!='+')continue;
			int ans = n;
			{
				// right
				int t = 0;
				for(int x=j+1;x<=m;x++){
					if(grid[i][x]!='-')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// left
				int t = 0;
				for(int x=j-1;x;x--){
					if(grid[i][x]!='-')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// down
				int t = 0;
				for(int x=i+1;x<=n;x++){
					if(grid[x][j]!='|')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// up
				int t = 0;
				for(int x=i-1;x;x--){
					if(grid[x][j]!='|')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// right-down
				int t = 0;
				for(int x=1;i+x<=n and j+x<=m;x++){
					if(grid[i+x][j+x]!='\\')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// left-up
				int t = 0;
				for(int x=1;i-x>0 and j-x>0;x++){
					if(grid[i-x][j-x]!='\\')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// left-down
				int t = 0;
				for(int x=1;i+x<=n and j-x>0;x++){
					if(grid[i+x][j-x]!='/')break;
					t++;
				}
				ans = min(ans,t);
			}
			{
				// right-up
				int t = 0;
				for(int x=1;i-x>0 and j+x<=m;x++){
					if(grid[i-x][j+x]!='/')break;
					t++;
				}
				ans = min(ans,t);
			}
			ma = max(ma,ans);
		}
	}
	cout << ma << '\n';
}

詳細信息

answer.code: In function ‘int32_t main()’:
answer.code:12:16: error: missing template arguments before ‘grid’
   12 |         vector grid(n+1,vector<char>(m+1));
      |                ^~~~
answer.code:15:32: error: ‘grid’ was not declared in this scope
   15 |                         cin >> grid[i][j];
      |                                ^~~~
answer.code:21:28: error: ‘grid’ was not declared in this scope
   21 |                         if(grid[i][j]!='+')continue;
      |                            ^~~~
answer.code:27:44: error: ‘grid’ was not declared in this scope
   27 |                                         if(grid[i][x]!='-')break;
      |                                            ^~~~
answer.code:36:44: error: ‘grid’ was not declared in this scope
   36 |                                         if(grid[i][x]!='-')break;
      |                                            ^~~~
answer.code:45:44: error: ‘grid’ was not declared in this scope
   45 |                                         if(grid[x][j]!='|')break;
      |                                            ^~~~
answer.code:54:44: error: ‘grid’ was not declared in this scope
   54 |                                         if(grid[x][j]!='|')break;
      |                                            ^~~~
answer.code:63:44: error: ‘grid’ was not declared in this scope
   63 |                                         if(grid[i+x][j+x]!='\\')break;
      |                                            ^~~~
answer.code:72:44: error: ‘grid’ was not declared in this scope
   72 |                                         if(grid[i-x][j-x]!='\\')break;
      |                                            ^~~~
answer.code:81:44: error: ‘grid’ was not declared in this scope
   81 |                                         if(grid[i+x][j-x]!='/')break;
      |                                            ^~~~
answer.code:90:44: error: ‘grid’ was not declared in this scope
   90 |                                         if(grid[i-x][j+x]!='/')break;
      |                                            ^~~~