Namomo Namomo Cockfight Round 3

太难了

A

接着A题漏判好多, 真不如枚举简单
看代码吧, 一般是漏情况wa

#include <bits/stdc++.h>
#define all(n) (n).begin(), (n).end()
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define sqr(n) (n)*(n)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define IO ios::sync_with_stdio(0); cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef double db;

const int N = 1e5 + 5;

int n, m, _, k, t;

int main() {
    IO;
    cin >> n;
    string s; cin >> s;

    if (n == 4 || n == 3) {
        if (s == "NN") cout << "Impossible";
        else if (n == 4) cout << 'N';
        else if (n == 3) cout << 'Y';
    } else {
        if (s == "YY") cout << "Impossible";
        else cout <<  'Y';
    } 
    return 0;
}

B

先说无限刷命
t == 1, 显然

其他情况, 无非是跳完 k 之后能返回, 低 k - d 个

说白了就是跳个圈

1 9 2 8 3 7 4 6 5

发现没有隔一个跳一个

只要最大的循环圈大于 cd 即可

没有圈按顺序跳一个算一个

#include <bits/stdc++.h>
#define all(n) (n).begin(), (n).end()
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define sqr(n) (n)*(n)
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define IO ios::sync_with_stdio(0); cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef double db;

const int N = 2e5 + 5;

int n, m, _, k;
ll a[N];
int d[N] = {1, 1};

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    for (cin >> _; _; --_) {
        cin >> n >> m >> k >> a[1];
        rep (i, 2, n) {
            cin >> a[i];
            d[i] = 1 + (a[i] - a[i - 1] <= m);
        }

        int mx = n - 1 ? d[2] : 1;
        rep (i, 3, n)  {
            if (a[i] - a[i - 2] <= m) d[i] = d[i - 1] + 1;
            mx = max(mx, d[i]);
        }

        if (mx >= k) { cout << "niao!\n"; continue; }

        mx = 1;
        rep (i, 2, n)
            if (a[i] - a[i - 1] <= m) d[i] = d[i - 1] + 1;
            else mx = max(mx, d[i - 1]), d[i] = 1;
        
        cout << max(mx, d[n]) << '\n';
    }
    return 0;
}
posted @ 2020-07-19 19:06  洛绫璃  阅读(193)  评论(0编辑  收藏  举报