zoukankan      html  css  js  c++  java
  • 2020 camp-day-e

    题解

    暴力就行(如果n 3000,那就要优化成 n^2

    #include <cstdio>
    
    #define RE register
    #define FOR(i,a,b) for(RE int i=a;i<=b;++i)
    #define ROF(i,a,b) for(RE int i=a;i>=b;--i)
    #define sc(n) scanf("%d",&n)
    
    using namespace std;
    
    int m, n;
    int a[305], b[5], e[6];
    int tex[301][301];
    long long ans;
    
    int main()
    {
        sc(n);
        FOR(i, 1, n)
        {
            FOR(j, 1, n)tex[j][i] = tex[j][i - 1];
            sc(a[i]); tex[a[i]][i] += 1;
        }
        FOR(i, 1, 4)
        {
            sc(b[i]);
            FOR(j, 1, i - 1)
                if (b[i] == b[j])
                    if (j == 1)e[i - 2] = 1;
                    else if (j == 2)e[i] = 1;
                    else e[5] = 1;
        }
        FOR(i, 1, n - 3)
            FOR(j, i + 1, n - 2)
            {
                if (e[0] && a[i] != a[j])continue;
                if (!e[0] && a[i] == a[j])continue;
                FOR(x, j + 1, n - 1)
                    if ((e[1] && a[i] != a[x]) || (!e[1] && a[i] == a[x]))continue;
                    else if ((e[3] && a[j] != a[x]) || (!e[3] && a[j] == a[x]))continue;
                    else if (e[2])ans += tex[a[i]][n] - tex[a[i]][x];
                    else if (e[4])ans += tex[a[j]][n] - tex[a[j]][x];
                    else if (e[5]) ans += tex[a[x]][n] - tex[a[x]][x];
                    else ans += n - x - tex[a[i]][n] + tex[a[i]][x] - (!e[0]) * (tex[a[j]][n] - tex[a[j]][x]) - (!e[1] && !e[3]) * (tex[a[x]][n] - tex[a[x]][x]);
            }
        printf("%lld", ans);
        return 0;
    }
    

      

  • 相关阅读:
    05.设计模式_建造者模式
    04.设计模式_抽象工厂模式
    03.设计模式_工厂方法模式
    02.设计模式_单例模式
    01.设计模式_简单工厂模式
    cocos-js一些问题
    blender
    游戏编程模式
    Unity自动打包工具
    unity调用ios原生代码objective-c和回调
  • 原文地址:https://www.cnblogs.com/2aptx4869/p/12203522.html
Copyright © 2011-2022 走看看