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. c3p0+spring

    1. 首先是jdbc.properties属性文件的编写,便于数据库移植: datasource.driverClassName=oracle.jdbc.driver.OracleDriverdata ...

  2. Android开发之开机自动启动应用

    package com.raycloud.wolf.autostart; import android.content.BroadcastReceiver; import android.conten ...

  3. HDOJ 5045 Contest

    状压DP.. . . Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  4. 图像物体检測识别中的LBP特征

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/xinzhangyanxiang/article/details/37317863 图像物体检測识别中 ...

  5. file类简单操作

    file类可表示文件或文件夹 import java.io.File; import java.io.FilenameFilter; import java.io.IOException; impor ...

  6. iOS webView的常见属性和方法

    一.初始化与三种加载方式 UIWebView继承与UIView,因此,其初始化方法和一般的view一样,通过alloc和init进行初始化,其加载数据的方式有三种: 第一种: - (void)load ...

  7. HDU 3714/UVA1476 Error Curves

    Error Curves Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  8. 内核添加dts后,device和device_driver的match匹配的变动:通过compatible属性进行匹配【转】

    本文转载自:http://blog.csdn.net/ruanjianruanjianruan/article/details/61622053 内核添加dts后,device和device_driv ...

  9. Python(2)(基本输入输出语句)

    我们先来说输出:

  10. BZOJ_5311_贞鱼_决策单调性+带权二分

    BZOJ_5311_贞鱼_决策单调性+带权二分 Description 众所周知,贞鱼是一种高智商水生动物.不过他们到了陆地上智商会减半. 这不?他们遇到了大麻烦! n只贞鱼到陆地上乘车,现在有k辆汽 ...