QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#404543#4234. Tic Tac Toe Countinghdmmblz#Compile Error//C++141.8kb2024-05-04 07:36:202024-05-04 07:36:22

Judging History

This is the latest submission verdict.

  • [2024-05-04 07:36:22]
  • Judged
  • [2024-05-04 07:36:20]
  • Submitted

answer

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


int r, c;

bool inrange(int x, int y){
	return 0 <= x && x < r && 0 <= y && y < c;
}

int char2dir(char c){
	switch(c){
		case '>':
			return 0;
		case '^':
			return 1;
		case '<':
			return 2;
		case 'v':
			return 3;
	}
	assert(false);
	return -1;
}

int di[4]= {0, -1, 0, 1};
int dj[4] = {1, 0, -1, 0};

struct pos{
	int x;
	int y;
	bool operator!=(const pos rhs) const{
		return x != rhs.x || y != rhs.y;
	}
};


int main() {
	
	cin >> r >> c;
	vector<vector<char> > m(r, vector<char>(c));
	//vector<vector<int>> status(r, vector<int>(c, 0));
	//vector<vector<int>> value(r, vector<int>(c, 0));
	for(int i = 0; i < r; ++i){
		for(int j = 0; j < c;++j){
			cin >> m[i][j];
			//if (m[i][j] == '.'|| m[i][j] == '#') status[i][j] = 2;
		}
	}
	int mval = -1;
	int curx = 0;
	int cury = 0;
	
	for(int i = 0; i < r; ++i){
		for(int j = 0; j < c;++j){
			int count = 0;
			vector<vector<bool> > visited(r, vector<bool>(c, false)); 
			vector<vector<bool> > visited2(r, vector<bool>(c, false));
			if (m[i][j] == '.'|| m[i][j] == '#') continue;
			pos cur = {i, j};
			while(inrange(cur.x, cur.y) && m[cur.x][cur.y] != '.' && m[cur.x][cur.y] != '#' && ){
				visited2[cur.x][cur.y]= true;
				for(int k = 0; k < 4; ++k){
					int nx = cur.x + di[k]; 
					int ny = cur.y+dj[k];
					if(inrange(nx, ny) && m[nx][ny] == '#'){
						visited[i][j] = true;
					}
				}
				int dir = char2dir(m[cur.x][cur.y]);
				cur = {cur.x + di[dir], cur.y+ di[dir]};
				start = false;
			}
			for(int x = 0; x < r; ++x){
				for(int y = 0; y < c; ++y){
					if(visited[i][j]){
						++count;
					}
				}
			}
			if(count > mval){
				mval = count;
				curx = i;
				cury = j;
			}
		}
	} 
	cout << mval << '\n';
}

Details

answer.code: In function ‘int main()’:
answer.code:62:108: error: expected primary-expression before ‘)’ token
   62 |                         while(inrange(cur.x, cur.y) && m[cur.x][cur.y] != '.' && m[cur.x][cur.y] != '#' && ){
      |                                                                                                            ^
answer.code:73:33: error: ‘start’ was not declared in this scope
   73 |                                 start = false;
      |                                 ^~~~~