2012-2013 ACM-ICPC Northeastern European Regional Contest (NEERC 12)
# | 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)的更多相关文章
- 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 个时刻 ...
- 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 ...
- 2015-2016 ACM-ICPC Northeastern European Regional Contest (NEERC 15)C - Cactus Jubilee
题意:给一颗仙人掌,要求移动一条边,不能放在原处,移动之后还是一颗仙人掌的方案数(仙人掌:无向图,每条边只在一个环中),等价于先删除一条边,然后加一条边 题解:对于一颗仙人掌,分成两种边,1:环边:环 ...
- 2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17) 日常训练
A - Archery Tournament 题目大意:按时间顺序出现靶子和射击一个位置,靶子的圆心为(x, y)半径为r,即圆与x轴相切,靶子不会重叠,靶子被击中后消失, 每次射击找出哪个靶子被射中 ...
- 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, ...
- 2002-2003 ACM-ICPC Northeastern European Regional Contest (NEERC 02) A Amusing Numbers (数学)
其实挺简单的.先直接算出之前已经排在k这个数前面的数字.比如543是三位的,那么100~543都是可以的,两位的10~54. 如果还需要往前面补的话,那么依次考虑1000~5430,5430是上界不能 ...
- 2015-2016 ACM-ICPC Northeastern European Regional Contest (NEERC 15)
NEERC 15 题解1 题解2 官方题解
- 2002-2003 ACM-ICPC Northeastern European Regional Contest (NEERC 02)
B Bricks 计算几何乱搞 题意: 给你个立方体,问你能不能放进一个管道里面. 题解: 这是一道非常迷的题,其问题在于,你可以不正着放下去,你需要斜着放.此时你需要枚举你旋转的角度,来判断是否可行 ...
- 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 ...
随机推荐
- Citrix Xen Desktop安装配置
Citrix虚拟化的东西其实和我现在做的东西完全没有关系的.反正接到通知要搭一个Citrix Xen Desktop那就做. 先放几个教程: :跟着图片通过XenDesktop7发布Win8桌面 这个 ...
- python3 下的文件输入输出特性以及如何覆盖文件内容和接下去输入
今天碰到了一个非常有意思的python特性.本来我是想打开一个文件,在文件的末尾接下去输入一些内容的,代码如下: f = open('test.txt', 'r+') f.write(content) ...
- 洛谷10月月赛Round.1| P3398 仓鼠找sugar[LCA]
题目描述 小仓鼠的和他的基(mei)友(zi)sugar住在地下洞穴中,每个节点的编号为1~n.地下洞穴是一个树形结构.这一天小仓鼠打算从从他的卧室(a)到餐厅(b),而他的基友同时要从他的卧室(c) ...
- mysql 有两种数据库引擎发音
mysql 有两种数据库引擎 一种是 MyISAM,一种是 InnoDB MyISAM 发音为 "my-z[ei]m"; InnoDB 发音为 "in-no-db&quo ...
- ssh远程执行目标机器上的命令
一句话: ssh -t -p 端口号 用户名@远程机器IP '远程机器上的命令完整路径' 例如: ssh -t -p 22 yangjunming@dev '/opt/app/deploy.sh' 注 ...
- HTML编写需要注意的事项
HTML在编写过程中需要注意许多关键的事项,就如最近我在学习中遇到的问题如下: 代码规范问题: 在代码视图中编写代码,一定要规范的格式,不要把代码全部都写到一块,这样不仅影响效率,更加影响视觉,当出现 ...
- LeetCode 笔记系列13 Jump Game II [去掉不必要的计算]
题目: Given an array of non-negative integers, you are initially positioned at the first index of the ...
- MFC vs2012 Office2013 读写excel文件
近期在忙一个小项目(和同学一起搞的),在这里客户要求不但读写txt,而且可以读写excel文件,这里本以为很简单,结果...废话少说,过程如下: 笔者环境:win7 64+VS2012+Office2 ...
- 【跟着子迟品 underscore】Array Functions 相关源码拾遗 & 小结
Why underscore 最近开始看 underscore.js 源码,并将 underscore.js 源码解读 放在了我的 2016 计划中. 阅读一些著名框架类库的源码,就好像和一个个大师对 ...
- 【JavaScript】操作Canvas画图
1.页面添加 Canvas 标签 标签内可以写文字,浏览器不支持Canvas的情况下显示, 2.js获取 Canvas 标签 3.利用js函数画图,[线][图][文字] 源:http://www.li ...