CodeForces 711A Bus to Udayland (水题)

Posted dwtfukgv

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces 711A Bus to Udayland (水题)相关的知识,希望对你有一定的参考价值。

题意:给定一个n*4的矩阵,然后O表示空座位,X表示已经有人了,问你是不能找到一对相邻的座位,都是空的,并且前两个是一对,后两个是一对。

析:直接暴力找就行。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <list>
#include <sstream>
#define frer freopen("in.txt", "r", stdin)
#define frew freopen("out.txt", "w", stdout)
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e3 + 5;
const int mod = 1e9 + 7;
const int dr[] = {-1, 1, 0, 0, 1, 1, -1, -1};
const int dc[] = {0, 0, 1, -1, 1, -1, 1, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
    return r >= 0 && r < n && c >= 0 && c < m;
}
char s[maxn][10];

int main(){
    while(cin >> n){
        bool ok = false;
        for(int i = 0; i < n; ++i){
            scanf("%s", &s[i]);
            if(!ok && s[i][0] == ‘O‘ && s[i][1] == ‘O‘){
                s[i][0] = s[i][1] = ‘+‘;
                ok = true;
            }
            else if(!ok && s[i][3] == ‘O‘ && s[i][4] == ‘O‘){
                s[i][3] = s[i][4] = ‘+‘;
                ok = true;
            }
        }
        printf("%s\n", ok ? "YES" : "NO");
        if(ok)
            for(int i = 0; i < n; ++i)
                puts(s[i]);
    }
    return 0;
}

 

以上是关于CodeForces 711A Bus to Udayland (水题)的主要内容,如果未能解决你的问题,请参考以下文章

[Codeforces 864C]Bus

Codeforces 864 C Bus 思维

Codeforces Round #436 C. Bus

CodeForces - 864C-Bus-(模拟加油站问题)

Codeforces Gym 101521A Shuttle Bus

Codeforces 982 B. Bus of Characters(模拟一个栈)