码迷,mamicode.com
首页 > 其他好文 > 详细

The 2016 ACM-ICPC Asia Shenyang Regional Contest

时间:2018-10-05 21:05:48      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:acm   highlight   star   cli   main   mes   ssi   space   span   

 

 

A. Thickest Burger

大数 × 2 + 小数

#include <cstdio>
#include <algorithm>
using namespace std;

int T;
int A,B;
int main()
{
    scanf("%d",&T);
    for(int t=1; t<=T; t++)
    {
        scanf("%d%d",&A,&B);
        if(A<B) swap(A,B);
        printf("%d\n",A*2+B);
    }
    return 0;
}

  

 

 

B. Relative atomic mass

 

 

 

 

C. Recursive sequence

 

 

 

D. Winning an Auction

 

 

 

E. Counting Cliques

爆搜。vector[i] 记录与 i 有边且编号大于的点。

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 100 + 10;
const int maxm = 1000 + 100;

int n, m, k;
vector<int> v[maxn];
int from[maxm], to[maxm];
int G[maxn][maxn];
int d[maxn], node[maxn];
int tot, ans;

void DFS(int x, int start)
{
    if (tot == k) { ++ans; return; }

    int sz = v[x].size();
    for (int i = start; i < sz; i++)
    {
        int flag = 0;
        for (int j = 2; j <= tot; j++)
        if (!G[ node[j] ][ v[x][i] ]) { flag = 1; break; }

        if (flag) continue;

        node[++tot] = v[x][i], DFS(x, i+1), --tot;
    }
}

int main()
{
    int t;
    scanf("%d", &t);
    for (int ca = 1; ca <= t; ca++)
    {
        memset(d, 0, sizeof(d));
        for (int i = 1; i <= n; i++)
        {
            for (int j = i+1; j <= n; j++) G[i][j] = G[j][i] = 0;
            v[i].clear();
        }

        scanf("%d%d%d", &n, &m, &k);
        for (int i = 1; i <= m; i++)
        {
            scanf("%d%d", &from[i], &to[i]);
            d[ from[i] ]++, d[ to[i] ]++;
        }

        for (int i = 1; i <= m; i++)
            if (d[ from[i] ] >= k-1 && d[ to[i] ] >= k-1)
            {
                if (from[i] < to[i]) v[ from[i] ].push_back(to[i]);
                    else v[ to[i] ].push_back(from[i]);
                G[ from[i] ][ to[i] ] = G[ to[i] ][ from[i] ] = 1;
            }

        ans = 0;
        for (int i = 1; i <= n; i++)
        {
            tot = 1, node[1] = i;
            DFS(i, 0);
        }

        printf("%d\n", ans);
    }
}

  

 

 

F. Similar Rotations

 

 

 

G. Do not pour out

 

 

 

H. Guessing the Dice Roll

 

 

 

I. The Elder

 

 

 

J. Query on a graph

 

 

 

K. New Signal Decomposition

 

 

 

L. A Random Turn Connection Game

 

 

 

M. Subsequence

 

The 2016 ACM-ICPC Asia Shenyang Regional Contest

标签:acm   highlight   star   cli   main   mes   ssi   space   span   

原文地址:https://www.cnblogs.com/ruthank/p/9745797.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!