Problems

 
 
# Name    
A
addictive.in / addictive.out

2 s, 256 MB

   x438
B
standard input/output

2 s, 256 MB

   x124
C
caravan.in / caravan.out

2 s, 256 MB

   x178
D
disjoint.in / disjoint.out

2 s, 256 MB

   x34
E
exact.in / exact.out

2 s, 256 MB

   x220
F
folding.in / folding.out

2 s, 256 MB

   x76
G
great.in / great.out

2 s, 256 MB

   x359
H
hyperdrome.in / hyperdrome.out

2 s, 256 MB

   x268
I
identification.in / identification.out

2 s, 256 MB

   x29
J
jumping.in / jumping.out

2 s, 256 MB

   x95
K
kingdom.in / kingdom.out

2 s, 256 MB

   
L
labyrinth.in / labyrinth.out

2 s, 256 MB

   x53

A.构造,水题。

 #include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; typedef double DB;
typedef long long ll;
typedef pair<int, int> PII; #define pb push_back
#define MP make_pair
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define re freopen("addictive.in", "r", stdin)
#define we freopen("addictive.out", "w", stdout)
#define FOR(i,x,y) for(i=x;i<=y;i++)
#define FORD(i,x,y) for(i=x;
#define REP(i,x) for(i=0;i<x;i++)
#define mf1(x) memset(x,-1,sizeof(x))
#define mz(x) memset(x,0,sizeof(x))
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z) const int maxn=;
const int maxm=;
const int INF=; int h,w,c;
int a[maxn]; int an[maxn][maxn]; void farm(){
int i,j,k,l,m;
k=;
j=;
l=;
mz(an);
REP(i,h){
REP(m,w){
while(a[l]==)l++;
an[i][j]=l;
a[l]--;
j+=k;
}
j-=k;
k=-k;
}
} int main(){
re;
we;
int i,j;
while(RD3(h,w,c)!=EOF){
FOR(i,,c)scanf("%d",&a[i]);
farm();
REP(i,h){
REP(j,w)printf("%d",an[i][j]);
puts("");
}
}
}

C.long double二分答案,最后枚举分母找一个分子。

 //#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) printf("%d\n",x);
#define RE freopen("caravan.in","r",stdin)
#define WE freopen("caravan.out","w",stdout)
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD; const LD pi=acos(-1.0);
const LD eps=1e-; const int maxn=; struct qj{
int l,r;
}a[maxn]; bool cmp(qj x, qj y){
return x.l < y.l;
} int n; int ans0,ans1; bool ok(LD x){
int i;
LD y=0.0;
REP(i,n){
if(a[i].r - x + eps < y)return ;
y = max((LD)a[i].l , y) + x;
}
return ;
} void farm(){
int i;
LD l=0.0,r=10000000.0,mid;
REP(i,n)r=min(r , (LD)(a[i].r-a[i].l));
sort(a,a+n,cmp);
while(r-l>eps){
mid=(l+r)*0.5;
if(ok(mid))l=mid;
else r=mid;
}
LD dou=1.0;
FOR(i,,){
if( fabs(r*i - (LD)ceil(r*i))<dou){
ans0=ceil(r*i);
ans1=i;
dou=fabs(r*i - (LD)ceil(r*i));
}
if( fabs(r*i - (LD)floor(r*i))<dou){
ans0=floor(r*i);
ans1=i;
dou=fabs(r*i - (LD)floor(r*i));
}
}
} int main(){
RE;
WE;
int i;
while(scanf("%d",&n)!=EOF){
REP(i,n)RD2(a[i].l, a[i].r);
farm();
printf("%d/%d\n",ans0,ans1);
}
}

E.贪心,分成19种包,分别按大小排序,要取其中一种肯定是取那种最大的。每次取能处理最低的非零位的最重的包,让它产生尽量多的零。

 //#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) printf("%d\n",x);
#define RE freopen("exact.in","r",stdin)
#define WE freopen("exact.out","w",stdout)
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD; const LD pi=acos(-1.0);
const LD eps=1e-; ll X;
int n; struct Box {
ll n;
int i;
Box(int _i,ll _n) {
i=_i;
n=_n;
}
}; bool cmp(Box x, Box y) {
return x.n<y.n;
}
ll ten[];
vector<Box>a[]; vector<int>an; bool farm() {
int i,j,k;
REP(i,)sort(a[i].begin(),a[i].end(),cmp);
an.clear();
ll x=X;
ll t=;
k=;
while(x) {
while(k<= && x%ten[k+]==)k++;
int mai=-;
ll ma=;
//printf("x=%I64d , k=%d\n",x,k);
FOR(i,,k) {
if(!a[i].empty()) {
if(a[i].back().n * ten[i] >ma) {
mai=i;
ma=a[i].back().n * ten[i];
}
}
}
if(mai==-)return ;
an.pb(a[mai].back().i);
t += a[mai].back().n * ten[mai];
//printf("t=%I64d\n",t);
ll q;
if(x>t){
j=k;
while(x%ten[j+] <= t)j++;
if(j!=k)q=x%ten[j];
else q=t;
}else q=x;
x-=q;
t-=q;
a[mai].pop_back();
}
return ;
} void init() {
int i;
ten[]=;
FOR(i,,) {
ten[i]=ten[i-]*;
}
ten[]=*ten[];
} int main() {
RE;
WE;
init();
int i,x;
ll y;
while(scanf("%I64d%d",&X,&n)!=EOF) {
REP(i,)a[i].clear();
FOR(i,,n) {
scanf("%d%I64d",&x,&y);
a[x].pb(Box(i,y));
}
if(farm()) {
printf("%d\n",an.size());
if(!an.empty())printf("%d",an[]);
FOR(i,,an.size()-)printf(" %d",an[i]);
puts("");
} else puts("-1");
}
return ;
}

G.数位DP,写简单点就是记忆化搜索型的。

 #include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; typedef double DB;
typedef long long ll;
typedef pair<int, int> PII; #define pb push_back
#define MP make_pair
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define RE freopen("great.in", "r", stdin)
#define WE freopen("great.out", "w", stdout)
#define FOR(i,x,y) for(i=x;i<=y;i++)
#define FORD(i,x,y) for(i=x;
#define REP(i,x) for(i=0;i<x;i++)
#define mf1(x) memset(x,-1,sizeof(x))
#define mz(x) memset(x,0,sizeof(x))
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z) const int maxn=;
const int maxm=;
const int INF=; ll n;
int k; ll pow(int x){
int i;
ll re=;
REP(i,x)re*=k;
return re;
} int a[maxn];
ll f[maxn]; ll dfs(int w, bool limit){
if(w<) return ;
if(!limit && f[w]!=-)return f[w];
int maxi=limit?a[w]:k-;
if(w%==)maxi=;
ll re=;
int i;
FOR(i,,maxi){
re+=dfs(w-, limit && i==a[w]);
}
if(!limit)f[w]=re;
return re;
} ll farm(){
ll re=;
ll t=n;
ll w=;
ll m=;
int i,j;
while(t){
a[w]=t%k;
t/=k;
w++;
}
mf1(f);
return dfs(w-, );
} int main(){
RE;
WE;
int i,j;
while(scanf("%I64d%d",&n,&k)!=EOF){
printf("%I64d\n",farm());
}
}

H.状压。1~i中各个字母是奇数个还是偶数个,能用2^52种状态表示。状态R xor 状态L,得到的就是区间[L,R]的状态,其中有0个或1个1就是可行的。

用hash存之前出现过的状态,枚举那个唯一的一个1来统计,O(52n)这样。

 #include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <hash_map>
using namespace std;
using namespace stdext;
typedef double DB;
typedef long long ll;
typedef unsigned int usint;
typedef pair<int, int> PII; #define pb push_back
#define MP make_pair
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define RE freopen("hyperdrome.in", "r", stdin)
#define WE freopen("hyperdrome.out", "w", stdout)
#define FOR(i,x,y) for(i=x;i<=y;i++)
#define FORD(i,x,y) for(i=x;
#define REP(i,x) for(i=0;i<x;i++)
#define mf1(x) memset(x,-1,sizeof(x))
#define mz(x) memset(x,0,sizeof(x))
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z) const int maxn=;
const int maxm=;
const int INF=; char s[maxn];
int q[];
int n;
ll l[]; //hash_map<ll,ll>S; const ll NONE=-;
class hash {
public:
hash() {
memset(a,0xff,sizeof(a));
}
usint locate(ll x) {
usint l=x%MOD;
while(a[l]!=x&&a[l]!=NONE) l=l+;
return l;
}
void insert(ll x,ll va) {
usint l=locate(x);
if(a[l]==NONE) {
a[l]=x;
v[l]=va;
}
} void add(ll x) {
usint l=locate(x);
if(a[l]==NONE) {
a[l]=x;
v[l]=;
}else{
v[l]++;
}
} ll find(ll x) {
usint l=locate(x);
return a[l]==x?v[l]:;
}
void clear() {
memset(a,-,sizeof(a));
}
private:
static const usint MOD=;
ll a[MOD+];
usint v[MOD+];
} S; ll farm(){
int i,j;
ll x=;
ll re=;
S.clear();
S.insert(,);
REP(i,n){
x^=(l[q[s[i]]]);
FOR(j,,){
re+=S.find(x ^ l[j]);
}
re+=S.find(x);
S.add(x);
//printf("%I64d,%I64d,%I64d,%I64d\n",x,S[x],re,1LL<<q[s[i]]);
}
return re;
} void init(){
int i;
FOR(i,'a','z')q[i]=i-'a';
FOR(i,'A','Z')q[i]=i-'A'+;
FOR(i,,)l[i]=1LL<<i;
} int main(){
RE;
WE;
int i,j;
init();
while(scanf("%d",&n)!=EOF){
scanf(" %s",s);
printf("%I64d\n",farm());
}
}

2012-2013 ACM-ICPC Northeastern European Regional Contest (NEERC 12)的更多相关文章

  1. 2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17)

    2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17) A 题意:有 n 个时刻 ...

  2. Editing 2011-2012 ACM-ICPC Northeastern European Regional Contest (NEERC 11)

    NEERC 11 *wiki链接[[https://acm.ecnu.edu.cn/wiki/index.php?title=2011-2012_ACM-ICPC_Northeastern_Europ ...

  3. 2015-2016 ACM-ICPC Northeastern European Regional Contest (NEERC 15)C - Cactus Jubilee

    题意:给一颗仙人掌,要求移动一条边,不能放在原处,移动之后还是一颗仙人掌的方案数(仙人掌:无向图,每条边只在一个环中),等价于先删除一条边,然后加一条边 题解:对于一颗仙人掌,分成两种边,1:环边:环 ...

  4. 2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17) 日常训练

    A - Archery Tournament 题目大意:按时间顺序出现靶子和射击一个位置,靶子的圆心为(x, y)半径为r,即圆与x轴相切,靶子不会重叠,靶子被击中后消失, 每次射击找出哪个靶子被射中 ...

  5. 2002-2003 ACM-ICPC Northeastern European Regional Contest (NEERC 02) H Heroes Of Might And Magic (隐含dp)

    问题是求一个方案,实际隐含一个dp.法力是递减的,所以状态是DAG,对于一个确定的状态,我们贪心地希望英雄的血量尽量大. 分析:定义状态dp[i][p][h]表示是已经用了i的法力值,怪兽的位置在p, ...

  6. 2002-2003 ACM-ICPC Northeastern European Regional Contest (NEERC 02) A Amusing Numbers (数学)

    其实挺简单的.先直接算出之前已经排在k这个数前面的数字.比如543是三位的,那么100~543都是可以的,两位的10~54. 如果还需要往前面补的话,那么依次考虑1000~5430,5430是上界不能 ...

  7. 2015-2016 ACM-ICPC Northeastern European Regional Contest (NEERC 15)

    NEERC 15 题解1 题解2 官方题解

  8. 2002-2003 ACM-ICPC Northeastern European Regional Contest (NEERC 02)

    B Bricks 计算几何乱搞 题意: 给你个立方体,问你能不能放进一个管道里面. 题解: 这是一道非常迷的题,其问题在于,你可以不正着放下去,你需要斜着放.此时你需要枚举你旋转的角度,来判断是否可行 ...

  9. ACM ICPC 2010–2011, Northeastern European Regional Contest St Petersburg – Barnaul – Tashkent – Tbilisi, November 24, 2010

    ACM ICPC 2010–2011, Northeastern European Regional Contest St Petersburg – Barnaul – Tashkent – Tbil ...

随机推荐

  1. 透明ActionBar

    代码方式:    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceSta ...

  2. 解决webkit浏览器中js方法中使用window.event提示未定义的问题

    这实际上是一个浏览器兼容性问题,根源百度中一大堆,简要说就是ie中event对象是全局变量,所以哪里都能使用到,但是webkit内核的浏览器中却不存在这个全局变量event,而是以一个隐式的局部变量的 ...

  3. makefile之VPATH和vpath的使用

    来自阅读陈皓的<跟我一起写makefile> VPATH变量 在一些大的工程中,有大量的源文件,我们通常的做法是把这许多的源文件分类,并存放在不同的目录中.所以,当 make 需要去找寻文 ...

  4. 一维码:EAN-13码的识别

    1.一维码简述: 一维条码是一种能用于信息编码和信息自动识别的标准符号,是由一组宽度不同的黑白符号按一定规则交替排列编码组成的图形符号,用于表示一定的信息. 码制指条码符号的类型,不同的类型有不同的编 ...

  5. jdbc java数据库连接 3)Statement接口之执行DDL和DML语句的简化

    上一章的代码中,可以发现,jdbc执行DDL和DML有几个步骤都是一样的: 1)执行语句开始时,创建驱动注册对象.获取连接的数据库对象.创建Statement对象 // 创建驱动注册对象 Class. ...

  6. DbContext 和ObjectContext两者的区别

    http://blog.csdn.net/lvjin110/article/details/24642911 ObjectContext是一种模型优先的开发模式,DbContext是代码优先的开发模式 ...

  7. python-异常处理

    一.异常 异常是什么? 就是影响程序正常执行的事件,异常在程序执行的过程中发生,脚本发生异常时,我们需要捕获它,否则程序就会终止. 异常处理: 1.捕获异常:try:...except ..... w ...

  8. zookeeper安装

    http://blog.itpub.net/27099995/viewspace-1394831/ http://blog.csdn.net/huwei2003/article/details/491 ...

  9. Matlab && C-Mex Round 1

    前言:本篇文章主要通过一个简单的例子程序对C-Mex进行一个初步的说明.前期的环境搭建(包括安装Matlab和gcc编译器)就不在这里赘述了. 在看文章之前,建议初学者先检查一下Matlab的mex配 ...

  10. Writing Clean Code 读后感

    最近花了一些时间看了这本书,书名是 <Writing Clean Code ── Microsoft Techniques for Developing Bug-free C Programs& ...