Submission #578177

# Submission time Handle Problem Language Result Execution time Memory
578177 2022-06-16T07:10:42 Z amunduzbaev Chess Rush (CEOI20_chessrush) C++17
8 / 100
1 ms 316 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ar array
typedef int64_t ll;

const int mod = 1e9 + 7;
int n, m;

void Pawn(int i, int j){
	if(i != j){
		cout<<0<<" "<<0<<"\n";
		return;
	}
	
	cout<<n - 1<<" "<<1<<"\n";
}

void Rook(int i, int j){
	if(i == j){
		cout<<1<<" "<<1<<"\n";
	} else {
		cout<<2<<" "<<2<<"\n";
	}
}

void Queen(int i, int j){
	ar<int, 2> d1 {}, d2 {};
	d1[0] = 1 + i, d2[0] = n + j;
	d1[1] = 1 - i, d2[1] = n - j;
	if(i == j || d1[0] == d2[0] || d1[1] == d2[1]){
		cout<<1<<" "<<1<<"\n";
		return;
	}
	
	cout<<2<<" ";
	int cnt = 2;
	if((d1[0] + d2[1]) % 2 == 0){
		int x = (d1[0] + d2[1]) / 2;
		int y = d1[0] - x;
		if(1 <= x && x <= n && 1 <= y && y <= m){
			cnt++;
		}
	}
	
	if((d1[1] + d2[0]) % 2 == 0){
		int x = (d1[1] + d2[0]) / 2;
		int y = d2[0] - x;
		if(1 <= x && x <= n && 1 <= y && y <= m){
			cnt++;
		}
	}
	
	{
		int y = j, x = d1[0] - y;
		if(1 <= x && x <= n){
			cnt += 2;
		}
		
		x = d1[1] + y;
		if(1 <= x && x <= n){
			cnt += 2;
		}
		
		x = n;
		y = d1[0] - x;
		if(1 <= y && y <= m){
			cnt++;
		}
		
		y = x - d1[1];
		if(1 <= y && y <= m){
			cnt++;
		}
		
		x = 1;
		y = d2[0] - x;
		if(1 <= y && y <= m){
			cnt++;
		}
		
		y = x - d2[1];
		if(1 <= y && y <= m){
			cnt++;
		}
	}
	
	cout<<cnt<<"\n";
}

int bp(int a, int b){
	int c = 1;
	while(b){
		if(b & 1) c = c * 1ll * a % mod;
		a = a * 1ll * a % mod, b >>= 1;
	} return c;
}

void King(int i, int j){
	int x = abs(i - j);
	int res = 1, inv = 1;
	for(int i = n; i < n + x; i++){
		res = (res * 1ll * i) % mod;
		inv = (inv * 1ll * (i - n + 1)) % mod;
	}
	
	cout<<x + n - 1<<" ";
	cout<<res * 1ll * bp(inv, mod - 2) % mod<<"\n";
}

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int q; cin>>n>>m>>q;
	while(q--){
		char c; cin>>c;
		int i, j; cin>>i>>j;
		if(c == 'P'){
			Pawn(i, j);
		} if(c == 'R'){
			Rook(i, j);
		} if(c == 'Q'){
			Queen(i, j);
		} if(c == 'K'){
			King(i, j);
		} if(c == 'B'){
			cout<<0<<" "<<0<<"\n";
		}
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -