QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#333837#4325. KraljiceivanjCompile Error//C++172.1kb2024-02-20 17:44:412024-02-20 17:44:41

Judging History

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

  • [2024-02-20 17:44:41]
  • 评测
  • [2024-02-20 17:44:41]
  • 提交

answer

#include<bits/stdc++.h>

#define pb push_back
#define x first
#define y second
#define all(a) (a).begin(), (a).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 1025;

int n;
int r[maxn];
int c[maxn];
int d1[maxn];
int d2[maxn];
int mat[maxn][maxn];
vector<ii> ans;

int check(int x, int y) {
	return (r[x] + c[y] + d1[x + y] + d2[x - y + n] + 1) % 2;
}

int play(int x, int y) {
	if((r[x] + c[y] + d1[x + y] + d2[x - y + n]) % 2) {
		cout << "err\n";
		exit(1);
	}
	ans.pb({x, y});
	mat[x][y] = 1;
	r[x]++, c[y]++, d1[x + y]++, d2[x - y + n]++;
}

void print() {
	for(int i = 0;i < n;i++, cout << "\n")
		for(int j = 0;j < n;j++) {	
			if(!mat[i][j]) cout << (r[i] + c[j] + d1[i + j] + d2[i - j + n]) % 2 << " ";
			else cout  << "X ";
		}
	cout << "..................................\n";
}

resi4() {
	play(0, 1);
	play(1, 3);
	play(0, 2);
	play(1, 0);
	play(1, 1);
	play(2, 3);
	play(0, 3);
	play(2, 0);
	play(2, 1);
	play(2, 2);
	play(3, 0);
	play(3, 2);
	play(3, 1);
	play(3, 3);
}

resi3() {
	play(1, 2);
	play(2, 0);
	play(1, 1);
	play(0, 0);
	play(2, 2);
	play(2, 1);
	play(0, 1);
	play(0, 2);
	play(1, 0);	
}
	
void rek(int n) {
	if(n <= 2) {play(0, 0);return;}
	if(n == 3) {resi3();return;}
	if(n == 4) {resi4();return;}
	rek(n - 2);
	
	for(int i = 0;i < n - 3;i++) {
		if(check(i, n - 1))
			play(i, n - 1), play(i, n - 2);
		else play(i, n - 2), play(i, n - 1);
		
		if(check(n - 1, i))
			play(n - 1, i), play(n - 2, i);
		else play(n - 2, i), play(n - 1, i);
	}
	
	if(n % 2 == 1) {
		play(n - 2, n - 1);
		play(n - 3, n - 2);
		play(n - 1, n - 2);
		play(n - 2, n - 2);
		play(n - 3, n - 1);
		play(n - 1, n - 3);
		play(n - 2, n - 3);
		play(n - 1, n - 1);	
	} else {
		play(n - 3, n - 1);	
		play(n - 3, n - 2);
		play(n - 2, n - 1);
		play(n - 2, n - 3);
		play(n - 1, n - 3);
		play(n - 2, n - 2);
		play(n - 1, n - 2);
		play(n - 1, n - 1);
	}
}

int main() {
	scanf("%d", &n);
	rek(n);
	printf("%d\n", (int)ans.size());
	for(ii p : ans)
		printf("%d %d\n", p.x + 1, p.y + 1);
	return 0;
}


Details

answer.code:46:1: error: ISO C++ forbids declaration of ‘resi4’ with no type [-fpermissive]
   46 | resi4() {
      | ^~~~~
answer.code: In function ‘int resi4()’:
answer.code:61:1: warning: no return statement in function returning non-void [-Wreturn-type]
   61 | }
      | ^
answer.code: At global scope:
answer.code:63:1: error: ISO C++ forbids declaration of ‘resi3’ with no type [-fpermissive]
   63 | resi3() {
      | ^~~~~
answer.code: In function ‘int resi3()’:
answer.code:73:1: warning: no return statement in function returning non-void [-Wreturn-type]
   73 | }
      | ^
answer.code: In function ‘int play(int, int)’:
answer.code:34:36: warning: control reaches end of non-void function [-Wreturn-type]
   34 |         r[x]++, c[y]++, d1[x + y]++, d2[x - y + n]++;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:113:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  113 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~