zoukankan      html  css  js  c++  java
  • 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!
    "; 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]) << '
    ';
        }
        return 0;
    }
    
  • 相关阅读:
    在类的外面调用类的private函数
    Django多表操作
    Django聚合与分组查询中value与annotate的顺序问题
    Django路由控制
    cookie与session的区别与关系
    面试题之改变对象的类
    python实现双向链表
    python实现单向循环链表
    python中的顺序表
    顺序表
  • 原文地址:https://www.cnblogs.com/2aptx4869/p/13340820.html
Copyright © 2011-2022 走看看