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;
    }
    

      

  • 相关阅读:
    超图 wpf地图控件加载地图
    MySql常用内容
    超图资料下载与环境安装
    超图SampleCode运行须知
    英语感叹词
    英语之妻子,老婆
    Pycharm设置
    yizhihx ubuntu config
    Ubuntu之网易云音乐无法启动
    linux之错误输出重定向
  • 原文地址:https://www.cnblogs.com/2aptx4869/p/12203522.html
Copyright © 2011-2022 走看看