A

暴力

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 1010
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
vector<int>ed[N];
bool w[N][N];
int main()
{
int i,j,n,m;
int flag = ;
cin>>n>>m;
for(i = ; i <= n;i++)
{
int k = ;
w[i][i] = ;
for(j = ; j <= n ; j++)
{
if(!w[i][j])
{
w[i][j] = ;
w[j][i] = ;
ed[i].push_back(j);
k++;
}
if(k==m) break;
}
if(k<m)
{
flag = ;
break;
}
}
if(!flag) {puts("-1");return ;}
printf("%d\n",n*m);
for(i = ; i <= n ;i++)
{
for(j = ; j < ed[i].size(); j++)
printf("%d %d\n",i,ed[i][j]);
}
return ;
}

B 状压

这个需要排下序,不然不能保证压的正确。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 1010
#define LL long long
//#define INF 1e18+1e12
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
const LL INF = (1ll<<);
LL dp[<<];
struct node
{
int x,k,m;
int a[];
int s;
}p[];
bool cmp(node a,node b)
{
return a.k<b.k;
}
int main()
{
int i,j,n,m;
LL b;
cin>>n>>m>>b;
for(i = ; i < (<<m) ; i++)
dp[i] = INF;
for(i = ; i <= n ;i++)
{
p[i].s = ;
scanf("%d%d%d",&p[i].x,&p[i].k,&p[i].m);
for(j = ; j < p[i].m ; j++)
{
scanf("%d",&p[i].a[j]);
p[i].s|=(<<(p[i].a[j]-));
}
}
sort(p+,p+n+,cmp);
dp[] = ;
LL ans= INF;
for(i = ; i <= n ;i++)
{
for(j = ;j < (<<m) ; j++)
{
if(dp[j]==INF) continue;
dp[j|p[i].s] = min(dp[j|p[i].s],dp[j]+p[i].x);
}
ans = min(ans,dp[(<<m)-]+p[i].k*b);
}
if(ans==INF)
puts("-1");
else
cout<<ans<<endl;
return ;
}

RCC 2014 Warmup (Div. 1)的更多相关文章

  1. RCC 2014 Warmup (Div. 2)

    一场很很多HACK的比赛,PREtest太弱了,真的很多坑!平时练习的时候很少注意这些东西了! A:开始一直在模拟,后来发现自己的思路逻辑很乱,果然做比赛不给力! 直接在代码中解释了 #include ...

  2. RCC 2014 Warmup (Div. 2) ABC

    题目链接 A. Elimination time limit per test:1 secondmemory limit per test:256 megabytesinput:standard in ...

  3. RCC 2014 Warmup (Div. 2) A~C

    近期CF的pretext真是一场比一场弱.第一次在CF上被卡cin.cout.... A. Elimination time limit per test 1 second memory limit ...

  4. RCC 2014 Warmup (Div. 2) 蛋疼解题总结

    A. Elimination time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  5. CodeForces - 417E(随机数)

    Square Table Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit ...

  6. CodeForces - 417B (思维题)

    Crash Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status ...

  7. CodeForces - 417A(思维题)

    Elimination Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit  ...

  8. Codeforces 417 C

    Football Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Sta ...

  9. CodeForces比赛总结表

    Codeforces A                     B                        C                             D            ...

随机推荐

  1. Window XP安装Ubuntu14.04实现Samba文件共享

    安装了Ubuntu14.04之后,在虚拟机设置里设置了文件共享.但在mnt文件夹下没有hgfs这个文件夹.依照网上说的去做还是不行,仅仅好放弃.改用samba实现Windows与Ubuntu文件共享. ...

  2. 文件批量转换成UTf-8

    yum install -y enca 在文件夹根目录下面创建文件:iconv_shell.sh 里面填写下面的内容: #!/bin/bash for file in `find ./ -name ' ...

  3. MySQL基本语句优化10个原则

    在数据库应用中,程序员们通过不断的实践总结了很多经验,这些经验是一些普遍适用的规则.每一个程序员都应该了解并记住它们,在构造SQL语句时,养成良好的习惯.以下10条比较重要的原则供大家参考. 原则1: ...

  4. iOS 如何改变表视图分割线在iOS7中的默认偏移

    - (void)viewDidLoad { [super viewDidLoad]; self.automaticallyAdjustsScrollViewInsets = NO; if ([self ...

  5. 基于Delphi7 WebService 在Apache发布及Apache使用说明

    基于Delphi7 WebService 在Apache 发布及Apache 使用说明 qq:394251165 前段时间,需要将基于Delphi7 WebService 发布在Apache, 很是苦 ...

  6. react native 之 redux

    第一章  认识redux 说的通俗且直白一点呢,就是redux提供了一个store,独立的一个内存区,然后放了一些state,你可以在任何component中访问到state,这些state要更改怎么 ...

  7. LR工作原理

    LoadRunner的总体架构图,包括各个组件VUGen, Controller和Analysis之间的关系. LoadRunner由四大组件组成:VuGen.控制器.负载发生器和分析器. 1.VuG ...

  8. ios 图片拉伸方法

     前提:要注意图片的size和展示的图片view的size的大小. 假如图片高度50,展示图片view的高度30,拉伸会变成剪切. 如果图片尺寸不对,可以用mac自带的图片编辑器修改大小: 双击打开图 ...

  9. BZOJ_1916_[Usaco2010 Open]冲浪_分层图+拓扑排序+DP

    BZOJ_1916_[Usaco2010 Open]冲浪_分层图+拓扑排序+DP Description 受到秘鲁的马丘比丘的新式水上乐园的启发,Farmer John决定也为奶牛们建 一个水上乐园. ...

  10. 字符串转UTF-8码(%开头)

    var str = '中'; var code = encodeURI(str); console.log(code); // => %E4%B8%AD