Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴个代妈

Posted by KatrineYang at 2016-09-12 23:18:12 on Problem 1301
#include <iostream>
#include <string>
using namespace std;

int x,y;

bool inRange(int i, int j){
	return i >= 0 && i < x && j >= 0 && j < y;
}

int dir[4][2] = {{0,-1},{-1,0},{0,1},{1,0}};

int main() {
	string fei;
	while(1){
		cin >> fei;
		if(fei == "ENDOFINPUT") break;
		char mp[15][15];
		cin >> x >> y;
		int temp = x;
		x = y;
		y = temp;
		int laserCnt = 0;
		int xl[110], yl[110];
		bool keyi[15][15] = {0};
		bool ky = 1;
		for(int i = 0; i < x; i++){
			cin >> fei;
			for(int j = 0; j < y; j++){
				mp[i][j] = fei[j];
				if(fei[j] == 'S'){
					xl[laserCnt] = i, yl[laserCnt] = j;
					laserCnt++;
				}
				if(fei[j] == 'L'){
					keyi[i][j] = 1;
				}
			}
		}
		cin >> fei;
		bool live[4][15][15];
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < x; j++){
				for(int k = 0; k < y; k++){
					if(mp[j][k] != 'P') live[i][j][k] = 1;
					else live[i][j][k] = 0;
				}
			}
		}
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < laserCnt; j++){
				int sX = xl[j], sY = yl[j];
				while(inRange(sX, sY)){
					live[i][sX][sY] = 0;
					sX += dir[i][0], sY += dir[i][1];
				}
			}
		}

		for(int k = 1; k < x; k++){
			int round = k%4;
			int kqCnt = 0;
			for(int i = 0; i < y; i++){
				if(!keyi[k-1][i]) continue;
				if(!live[round][k-1][i]) continue;
				if(live[round][k][i]){
					keyi[k][i] = 1;
					kqCnt++;
				}
				if(inRange(k, i-1)){
					if(live[round][k][i-1] && (live[round][k][i] || live[round][k-1][i-1])){
						keyi[k][i-1] = 1;
						kqCnt++;
					}
				}
				if(inRange(k, i+1)){
					if(live[round][k][i+1] && (live[round][k][i] || live[round][k-1][i+1])){
						keyi[k][i+1] = 1;
						kqCnt++;
					}
				}
			}
			if(kqCnt == 0){
				ky = 0;
				break;
			}
		}
		if(ky){
			cout << "FERRET" << endl;
		}
		else{
			cout << "GARRET" << endl;
		}
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator