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. A Practical Introduction to Blockchain with Python

    A Practical Introduction to Blockchain with Python // Adil Moujahid // Data Analytics and more http: ...

  2. IOS开发,知识点小结,ios开发中经常使用的宏定义总结

    IOS开发,从应用跳转到用浏览器打开网页: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http:// ...

  3. TFS Server 2017 自动化部署步骤

    1 第一步,在服务器上安装TFS 2 第二步,安装完TFS后需要配置你的项目,选择管理代码的方式,这里我们可以选择传统的TFS 也可以选择GIT 方式,此处我选择的GIT 方式 3 第三步,设置代理. ...

  4. MyEclipse 8.5 启动过程优化

    前言:MyEclipse5.5 大小 139M:MyEclipse6.5 大小 451M:MyEclipse7.0 大小 649M:MyEclipse8.0 大小 772.3MB(速度方面比7.1和7 ...

  5. 获取浏览器屏幕高度(js,jq)

    javascript IE中:document.body.clientWidth ==> BODY对象宽度document.body.clientHeight ==> BODY对象高度do ...

  6. Hive中的一些点

    hive严格模式 Hive中Order by和Sort by的区别是什么? hive中order by,sort by, distribute by, cluster by作用以及用法 Hadoop ...

  7. Hadoop 文件压缩

    一.目的 a. 减小磁盘占用 b. 加速网络IO 二.几个常用压缩算法 是否可切分:是指压缩后的文件能否支持在任意位置往后读取数据. 各种压缩格式特点: 压缩算法都需要权衡 空间/时间 :压缩率越高, ...

  8. POJ2243 Knight Moves —— A*算法

    题目链接:http://poj.org/problem?id=2243 Knight Moves Time Limit: 1000MS   Memory Limit: 65536K Total Sub ...

  9. 理解 Android MVP 开发模式

    /***************************************************************************************** * 理解 Andr ...

  10. oracle 在insert into的时候报ORA-00928: missing SELECT keyword错 [问题点数:100分,结帖人dm520]

    转自:https://bbs.csdn.net/topics/310095274 INSERT INTO SA_Table(uniPositionCode,transferGroupName,appC ...