RCC 2014 Warmup (Div. 1)
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)的更多相关文章
- RCC 2014 Warmup (Div. 2)
一场很很多HACK的比赛,PREtest太弱了,真的很多坑!平时练习的时候很少注意这些东西了! A:开始一直在模拟,后来发现自己的思路逻辑很乱,果然做比赛不给力! 直接在代码中解释了 #include ...
- RCC 2014 Warmup (Div. 2) ABC
题目链接 A. Elimination time limit per test:1 secondmemory limit per test:256 megabytesinput:standard in ...
- RCC 2014 Warmup (Div. 2) A~C
近期CF的pretext真是一场比一场弱.第一次在CF上被卡cin.cout.... A. Elimination time limit per test 1 second memory limit ...
- RCC 2014 Warmup (Div. 2) 蛋疼解题总结
A. Elimination time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- CodeForces - 417E(随机数)
Square Table Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- CodeForces - 417B (思维题)
Crash Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Status ...
- CodeForces - 417A(思维题)
Elimination Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- Codeforces 417 C
Football Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Sta ...
- CodeForces比赛总结表
Codeforces A B C D ...
随机推荐
- IOS开发,知识点小结,ios开发中经常使用的宏定义总结
IOS开发,从应用跳转到用浏览器打开网页: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http:// ...
- golang-----golang sync.WaitGroup解决goroutine同步
go提供了sync包和channel来解决协程同步和通讯.新手对channel通道操作起来更容易产生死锁,如果时缓冲的channel还要考虑channel放入和取出数据的速率问题. 从字面就可以理解, ...
- YTU 1068: 复制字符串
1068: 复制字符串 时间限制: 1 Sec 内存限制: 128 MB 提交: 602 解决: 382 题目描述 有一字符串,包含n个字符.写一函数,将此字符串中从第m个字符开始的全部字符复制成 ...
- putty与emacs
win环境下putty登录到linux并使用emacs时,需要折腾好配置才能正常工作.下面是折腾过程中碰到的问题与解决步骤: 1)要在putty控制台中启用鼠标,只需要在.emacs配置文件中启用xt ...
- Unity5.6打包问题
将unity切换到5.6版本后打Android包时,提示android sdk tools version低于compile version,于是更新了android-sdk(下载了Android-S ...
- JS DOM1核心概要document
Document类型: document对象表示整个html页面,而且,document对象是window对象的一个属性: 文档信息:document.title,表示当前页面的标题: documen ...
- Apostrophe not preceded by \
编辑strings.xml的时候, <string name="start">Let's get started!</string> 报错说:“Apostr ...
- BZOJ_2726_[SDOI2012]任务安排_斜率优化+二分
BZOJ_2726_[SDOI2012]任务安排_斜率优化+二分 Description 机器上有N个需要处理的任务,它们构成了一个序列.这些任务被标号为1到N,因此序列的排列为1,2,3...N.这 ...
- 【转】nose-parameterized是Python单元测试框架实现参数化的扩展
原文地址: http://www.cnblogs.com/fnng/p/6580636.html 相对而言,Python下面单元测试框架要弱上少,尤其是Python自带的unittest测试框架,不支 ...
- JS两个数组比较,删除重复值巧妙方法
//方法一 var arr1 = [1,2,3,4,5,6,7,8]; //数组A var arr2 = [1,2,3,11,12,13,14];//数组B var temp = []; //临时数组 ...