Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- typedef struct pos{
- int row;
- int col;
- }pos;
- pos ctrl[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; /// N E S W
- pos stand[5];
- vector<vector<int>> table;
- vector<vector<char>> mov(5);
- vector<int> score(5, 1);
- vector<int> winner;
- int t, r, c, mx, sum;
- char cmd;
- void PrintTable(){
- for(int i = 1; i <= t; ++i){
- for(int j = 1; j <= t; ++j){
- cout << table[i][j] << " ";
- }
- cout << "\n";
- }
- return;
- }
- void PrintScore(){
- cout << "Score\n";
- for(int i = 1; i <= 4; ++i){
- cout << score[i] << " ";
- }
- cout << "\n";
- return;
- }
- int main(){
- scanf("%d", &t);
- table.assign(t + 1, vector<int>(t + 1, 0));
- scanf("%d", &r);
- table[1][t] = 1;
- stand[1] = {1, t};
- table[t][t] = 2;
- stand[2] = {t, t};
- table[t][1] = 3;
- stand[3] = {t, 1};
- table[1][1] = 4;
- stand[4] = {1, 1};
- for(int i = 1; i <= 4; ++i){
- for(int j = 0; j < r; ++j){
- scanf(" %c", &cmd);
- mov[i].push_back(cmd);
- }
- }
- for(int i = 0; i < r; ++i){
- for(int p = 1; p <= 4; ++p){
- cmd = mov[p][i];
- switch(cmd){
- case 'N':
- c = 0;
- break;
- case 'E':
- c = 1;
- break;
- case 'S':
- c = 2;
- break;
- case 'W':
- c = 3;
- break;
- }
- if(stand[p].row + ctrl[c].row > 0 && stand[p].row + ctrl[c].row <= t && stand[p].col + ctrl[c].col > 0 && stand[p].col + ctrl[c].col <= t){
- bool pass = true;
- for(int j = 1; j <= 4; ++j){
- if(stand[p].row + ctrl[c].row == stand[j].row && stand[p].col + ctrl[c].col == stand[j].col){
- pass = false;
- }
- }
- if(pass){
- if(table[stand[p].row + ctrl[c].row][stand[p].col + ctrl[c].col] != 0){
- --score[table[stand[p].row + ctrl[c].row][stand[p].col + ctrl[c].col]];
- }
- table[stand[p].row + ctrl[c].row][stand[p].col + ctrl[c].col] = p;
- ++score[p];
- stand[p].row += ctrl[c].row;
- stand[p].col += ctrl[c].col;
- }
- }
- }
- }
- mx = 0;
- sum = 0;
- for(int i = 1; i <= 4; ++i){
- sum += score[i];
- if(score[i] > mx){
- winner.clear();
- mx = score[i];
- winner.push_back(i);
- } else if(score[i] == mx){
- winner.push_back(i);
- }
- }
- if(sum < t * t){
- cout << "No";
- } else {
- cout << winner.size() << " " << mx << "\n";
- for(auto x : winner){
- cout << x << "\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement