2013-2014 ACM-ICPC, NEERC, Eastern Subregional Contest PART (8/10)
$$2013-2014\ ACM-ICPC,\ NEERC,\ Eastern\ Subregional\ Contest$$
\(A.Podracing\)
首先枚举各个折现上的点,找出最小宽度,然后找每个存在摄像头的\(y\)值,在这个\(y\)坐标下找到最大间隔,和答案取\(max\)即可
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 1e5+7;
int n,m,q;
pair<double,double> lb[MAXN],rb[MAXN],cam[MAXN];
double res = 3e9+7;
void checkbod(){
for(int i = 1; i <= n; i++){
int p = lower_bound(rb+1,rb+1+m,lb[i],[](const pair<double,double> A, const pair<double,double> B){
return A.second<B.second;
}) - rb;
if(rb[p].second==lb[i].second){
res = min(res,double(rb[p].first-lb[i].first));
continue;
}
auto p1 = rb[p-1], p2 = rb[p];
double x = p1.first+(p2.first-p1.first)*(lb[i].second-p1.second)/(p2.second-p1.second);
res = min(res,x-lb[i].first);
}
for(int i = 1; i <= m; i++){
int p = lower_bound(lb+1,lb+1+n,rb[i],[](const pair<double,double> A, const pair<double,double> B){
return A.second<B.second;
}) - lb;
if(lb[p].second==rb[i].second){
res = min(res,double(rb[i].first-lb[p].first));
continue;
}
auto p1 = lb[p-1], p2 = lb[p];
double x = p1.first+(p2.first-p1.first)*(rb[i].second-p1.second)/(p2.second-p1.second);
res = min(res,rb[i].first-x);
}
}
void check(vector<int> &vec){
if(vec.empty()) return;
double y = cam[vec.back()].second;
if(y>lb[n].second||y<lb[1].second) return;
double lbord,rbord;
int p;
p = lower_bound(lb+1,lb+1+n,make_pair(0,y),[](const pair<double,double> A,const pair<double,double> B){
return A.second < B.second;
}) - lb;
if(lb[p].second==y) lbord = lb[p].first;
else{
auto p1 = lb[p-1], p2 = lb[p];
lbord = p1.first+(p2.first-p1.first)*1.0*(y-p1.second)/(p2.second-p1.second);
}
p = lower_bound(rb+1,rb+1+m,make_pair(0,y),[](const pair<double,double> A,const pair<double,double> B){
return A.second < B.second;
}) - rb;
if(rb[p].second==y) rbord = rb[p].first;
else{
auto p1 = rb[p-1], p2 = rb[p];
rbord = p1.first+(p2.first-p1.first)*1.0*(y-p1.second)/(p2.second-p1.second);
}
vector<double> xpos;
xpos.emplace_back(lbord);
sort(vec.begin(),vec.end(),[](int A, int B){
return cam[A].first < cam[B].first;
});
for(int ID : vec){
if(cam[ID].first<xpos.back()) continue;
xpos.emplace_back(cam[ID].first);
}
while(xpos.back()>rbord) xpos.pop_back();
xpos.emplace_back(rbord);
double maxwidth = 0;
for(int i = 1; i < (int)xpos.size(); i++) maxwidth = max(maxwidth,xpos[i]-xpos[i-1]);
res = min(res,maxwidth);
}
void checkcam(){
sort(cam+1,cam+1+q,[](const pair<double,double> A, const pair<double,double> B){ return A.second < B.second; });
int cur = 1;
vector<int> vec;
cam[0].second = -2e9;
while(cur<=q){
if(cam[cur].second==cam[cur-1].second){
vec.emplace_back(cur++);
continue;
}
check(vec);
vec.clear();
vec.emplace_back(cur++);
}
check(vec);
}
int main(){
scanf("%d",&n);
for(int i = 1; i <= n; i++) scanf("%lf %lf",&lb[i].first,&lb[i].second);
scanf("%d",&m);
for(int i = 1; i <= m; i++) scanf("%lf %lf",&rb[i].first,&rb[i].second);
scanf("%d",&q);
for(int i = 1; i <= q; i ++) scanf("%lf %lf",&cam[i].first,&cam[i].second);
checkbod();
checkcam();
printf("%.6f\n",res);
return 0;
}
\(B.The\ battle\ near\ the\ swamp\)
签到
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 1e4+7;
int n,m;
int main(){
scanf("%d %d",&n,&m);
int lft = 0, ene = 0;
for(int x,i = 1; i <= n; i++){
scanf("%d",&x);
if(x>m) lft+=x-m;
else ene+=m-x;
}
cout << lft << ' ' << ene << endl;
return 0;
}
\(C.CVS\)
可持久化链表,可以用链式前向星
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 5e5+7;
struct CVS{
int tot;
CVS(){ tot = 1; }
struct NODE{
NODE *pre;
int ID;
NODE(int id = 0){
pre = nullptr;
ID = id;
}
};
struct Kamino{
NODE *ltail,*ttail;
Kamino(){
ltail = new NODE;
ttail = new NODE;
}
}kam[MAXN];
void learn(int ID, int p){
kam[ID].ttail = new NODE;
NODE* node = new NODE(p);
node->pre = kam[ID].ltail;
kam[ID].ltail = node;
}
void rollback(int ID){
NODE* node = new NODE(kam[ID].ltail->ID);
node->pre = kam[ID].ttail;
kam[ID].ttail = node;
kam[ID].ltail = kam[ID].ltail->pre;
}
void relearn(int ID){
NODE* node = new NODE(kam[ID].ttail->ID);
node->pre = kam[ID].ltail;
kam[ID].ltail = node;
kam[ID].ttail = kam[ID].ttail->pre;
}
void clone(int ID){
tot++;
kam[tot] = kam[ID];
}
int check(int ID){
return kam[ID].ltail->ID;
}
}CVS;
int n,m;
int read(){
int x = 0, f = 1;
char c = getchar();
while(c!='-'&&(c<'0'||c>'9')) c = getchar();
if(c=='-') f = -1,c = getchar();
while(c>='0'&&c<='9') x = x*10+c-'0', c = getchar();
return f*x;
}
int main(){
n = read(); m = read();
while(n--){
char op[20];
scanf("%s",op);
if(op[0]=='l'){ //learn
int id=read(),p=read();
CVS.learn(id,p);
}
else if(op[1]=='o'){ //rollback
int id=read();
CVS.rollback(id);
}
else if(op[1]=='e'){ //relearn
int id=read();
CVS.relearn(id);
}
else if(op[1]=='l'){ //clone
int id=read();
CVS.clone(id);
}
else if(op[1]=='h'){ //check
int id=read();
if(CVS.check(id)) printf("%d\n",CVS.check(id));
else printf("basic\n");
}
}
return 0;
}
\(D.This\ cheeseburger\ you\ don't\ need\)
模拟
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const int inf = 0x3f3f3f3f;
string S[5];
int main(){
IOS;
string s;
string ans="";
int tar=0;
for(int i=0;i<3;i++)S[i]="";
int f=0;
while(cin>>s){
int len=s.length();
if(s[0]=='(')tar=0,f++;
if(s[0]=='[')tar=1,f++;
if(s[0]=='{')tar=2,f++;
if(s[len-1]==')')f++;
if(s[len-1]==']')f++;
if(s[len-1]=='}')f++;
if(s[len-2]==']')f++;
if(s[len-2]=='}')f++;
if(s[len-2]==')')f++;
if(f==0){
ans+=s+' ';
continue;
}
if(s[0]!='('&&s[0]!='['&&s[0]!='{')S[tar]+=s[0];
if(s[len-1]==',')S[tar]+=s.substr(1,max(0,len-3));
else S[tar]+=s.substr(1,max(0,len-2));
if(s[len-1]==','){
if(len>=3&&s[len-2]!=')'&&s[len-2]!=']'&&s[len-2]!='}')S[tar]+=s[len-2];
S[tar]+=' ';
if(f==6){
ans+=S[2];
ans+=S[0];
ans+=S[1].substr(0,S[1].length()-1)+", ";
f=0;
for(int i=0;i<3;i++)S[i].clear();
}
continue;
}
if(s[len-1]!=')'&&s[len-1]!=']'&&s[len-1]!='}'&&len!=1)S[tar]+=s[len-1];
S[tar]+=' ';
if(f==6){
ans+=S[2];
ans+=S[0];
ans+=S[1];
f=0;
for(int i=0;i<3;i++)S[i].clear();
}
}
int len=ans.length();
for(int i=0;i<len-1;i++){
if(i==0&&ans[i]>='a'&&ans[i]<='z')cout<<char(ans[i]-32);
else if(i!=0 && ans[i]>='A'&&ans[i]<='Z')cout<<char(ans[i]+32);
else cout<<ans[i];
}
return 0;
}
\(E.The\ Emperor's\ plan\)
组合数学 概率DP
\(f[x][y]\)表示当天晚上参议员中非spy的有\(x\)个,spy有\(y\)个的情况下,最终剩余非spy参议员的期望数量
边界条件是
1.\(x \le y\)这时非spy在晚上全被消灭,\(f[x][y]=0\)
2.\(y==0\) 这时全为非spy参议员,\(f[x][y]=x\)
然后依据题意进行\(dp\),每次枚举白天被票出的人的个数进行转移,用\(ln\)和\(exp\)保证精度正确
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 222;
double ln[MAXN],f[MAXN][MAXN];
double lnC(int A, int B){ return ln[A]-ln[B]-ln[A-B]; }
double percentage(int a, int x, int b, int y){ return exp(lnC(x,a)+lnC(y,b)-lnC(x+y,a+b)); }
double solve(int x, int y){
if(f[x][y]!=-1) return f[x][y];
if(x<=y) return f[x][y] = 0;
if(y==0) return f[x][y] = x;
x-=y;
int tot = x+y;
double res = 0;
for(int k = 1; k < tot; k++){
double tp = 0;
for(int i = max(0,k-y); i <= min(x,k); i++) tp += solve(x-i,y-k+i)*percentage(i,x,k-i,y);
res = max(res,tp);
}
return f[x+y][y] = res;
}
int n,k;
int main(){
ln[0] = 0;
for(int i = 1; i < MAXN; i++) ln[i] = ln[i-1]+log(i);
for(int i = 0; i < MAXN; i++) for(int j = 0; j < MAXN; j++) f[i][j] = -1;
scanf("%d %d",&n,&k);
printf("%.6f\n",solve(n-k,k));
return 0;
}
\(F.Illegal spices\)
题目保证答案存在,那就把前\(n-m\)个都设为\(1\),后面的\(m\)个贪心地取就好了
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 1e5+7;
int n,m,p;
vector<int> vec;
int main(){
scanf("%d %d %d",&n,&m,&p);
int_fast64_t sum = n - m;
int num = n - m, cur = 2;
for(int i = 1; i <= n-m; i++) vec.emplace_back(1);
for(int i = n-m+1; i <= n; i++){
if(num*100<p*(i-1)){
cur++;
num = i - 1;
}
sum+=cur;
vec.emplace_back(cur);
}
cout << sum << endl;
for(int x : vec) cout << x << ' ';
return 0;
}
\(G.Cipher\ Message\ 3\)
KMP+FFT 不会
\(H.Those\ are\ not\ the\ droids\ you're\ looking\ for\)
出入的时间分开跑二分图匹配即可,如果能完全匹配则说明没有说谎
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 1111;
int a,b,n,match[MAXN];
bool vis[MAXN];
vector<int> G[MAXN];
pair<int,int> sta[MAXN];
bool dfs(int u){
vis[u] = true;
for(int v : G[u]){
if(match[v]==-1||(!vis[match[v]]&&dfs(match[v]))){
match[v] = u;
return true;
}
}
return false;
}
int go(){
memset(match,255,sizeof(match));
int tot = 0;
for(int i = 1; i <= n; i++){
if(sta[i].second==0){
memset(vis,0,sizeof(vis));
if(dfs(i)) tot++;
else return tot;
}
}
return tot;
}
int main(){
scanf("%d %d %d",&a,&b,&n);
for(int i = 1; i <= n; i++) scanf("%d %d",&sta[i].first,&sta[i].second);
for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++){
if(sta[i].second==0&&sta[j].second==1&&(sta[j].first-sta[i].first>=a||(sta[j].first-sta[i].first<=b&&sta[j].first-sta[i].first>0))){
G[i].emplace_back(j);
}
}
if(go()*2==n){
printf("No reason\n");
for(int i = 1; i <= n; i++) if(sta[i].second==1){
printf("%d %d\n",sta[match[i]].first,sta[i].first);
}
}
else printf("Liar\n");
return 0;
}
\(I.The\ old\ Padawan\)
先双指针将每个点会回到的点找出来,然后暴力就行了
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
using LL = int_fast64_t;
const int MAXN = 1e5+7;
int n,m,cur;
LL k,A[MAXN],tk[MAXN],res,pos[MAXN];
int main(){
scanf("%d %d %I64d",&n,&m,&k);
for(int i = 1; i <= n; i++) scanf("%I64d",&A[i]);
int l = 0,r = 1;
LL sum = A[1];
while(r<=n){
while(sum-A[l+1]>k) sum-=A[++l];
pos[r] = l;
sum+=A[++r];
}
for(int i = 1; i <= m; i++) scanf("%I64d",&tk[i]);
for(int i = 1; i <= m; i++){
if(n-cur<tk[i]-res) break;
int dur = tk[i] - res - 1;
res += dur+1;
cur += dur;
cur = pos[cur];
}
if(cur<n) res+=n-cur;
cout << res << endl;
return 0;
}
\(J.The\ secret\ module\)
2013-2014 ACM-ICPC, NEERC, Eastern Subregional Contest PART (8/10)的更多相关文章
- 2018-2019 ICPC, NEERC, Southern Subregional Contest
目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...
- Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest
2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror) Solution
从这里开始 题目列表 瞎扯 Problem A Find a Number Problem B Berkomnadzor Problem C Cloud Computing Problem D Gar ...
- 2014-2015 ACM-ICPC, NEERC, Eastern Subregional Contest Problem G. The Debut Album
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229669 时间限制:1s 空间限制:64MB 题目大意:给定n,a,b的值 求一个长度为n的 ...
- 2014-2015 ACM-ICPC, NEERC, Eastern Subregional Contest Problem H. Pair: normal and paranormal
题目链接:http://codeforces.com/group/aUVPeyEnI2/contest/229669 时间限制:1s 空间限制:64MB 题目大意:给定一个长度为2n,由n个大写字母和 ...
- Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结
第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...
- codeforce1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) 题解
秉承ACM团队合作的思想懒,这篇blog只有部分题解,剩余的请前往星感大神Star_Feel的blog食用(表示男神汉克斯更懒不屑于写我们分别代写了下...) C. Cloud Computing 扫 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)
A. Find a Number 找到一个树,可以被d整除,且数字和为s 记忆化搜索 static class S{ int mod,s; String str; public S(int mod, ...
- 2018.10.20 2018-2019 ICPC,NEERC,Southern Subregional Contest(Online Mirror, ACM-ICPC Rules)
i207M的“怕不是一个小时就要弃疗的flag”并没有生效,这次居然写到了最后,好评=.= 然而可能是退役前和i207M的最后一场比赛了TAT 不过打得真的好爽啊QAQ 最终结果: 看见那几个罚时没, ...
随机推荐
- 机器学习算法-PCA降维技术
机器学习算法-PCA降维 一.引言 在实际的数据分析问题中我们遇到的问题通常有较高维数的特征,在进行实际的数据分析的时候,我们并不会将所有的特征都用于算法的训练,而是挑选出我们认为可能对目标有影响的特 ...
- 【Oracle】instr()函数详解
1)instr()函数的格式 (俗称:字符查找函数) 格式一:instr( string1, string2 ) / instr(源字符串, 目标字符串) 格式二:instr( strin ...
- 洛谷P1198 [JSOI2008]最大数(线段树/单调栈)
题目链接: https://www.luogu.org/problemnew/show/P1198 题目描述 现在请求你维护一个数列,要求提供以下两种操作: 1. 查询操作. 语法:Q L 功能:查询 ...
- python—打开图像文件报错
今天使用python打开一张图像文件的时候报错了 UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: illeg ...
- 实现简易版德州扑克|学习麻瓜编程以项目为导向入门前端 HTML+CSS+JS
实现简易版德州扑克 1.先上达到网页效果图(简易版德州扑克) 网页分为发牌区和牌池,上面为发牌区,下面是牌池区 2. 代码实现 2.1 HTML和JS代码 ` <link rel="s ...
- [Usaco2002 Feb]Rebuilding Roads重建道路
题目描述 一场可怕的地震后,奶牛用N个牲口棚(1 <= N <= 150,编号1..N)重建了农民John的牧场.奶牛没有时间建设多余的道路,所以现在从一个牲口棚到另一个牲口棚的道路是唯一 ...
- 24V转3.3V稳压芯片,高效率同步降压DC-DC变换器3A输出电流
PW2312是一个高频,同步,整流,降压,开关模式转换器与内部功率MOSFET.它提供了一个非常紧凑的解决方案,以实现1.5A的峰值输出电流在广泛的输入电源范围内,具有良好的负载和线路调节. PW23 ...
- mysql InnoDB架构
1.InnoDB的磁盘结构 1)系统表空间 2)用户表空间 3)rodolog 文件组 4)磁盘文件逻辑结构 文件->段->区->页->行 InnoDB对数据的存取是以页为单位 ...
- EL&Filter&Listener:EL表达式和JSTL,Servlet规范中的过滤器,Servlet规范中的监听器,观察着设计模式,监听器的使用,综合案例学生管理系统
EL&Filter&Listener-授课 1 EL表达式和JSTL 1.1 EL表达式 1.1.1 EL表达式介绍 *** EL(Expression Language):表达式语言 ...
- .NET Core 问题记录
前言: 最近在项目中遇到了遇到了写部署步骤过多的问题,为了减少.net core项目部署步骤:需要对一些基础问题进行验证: 如端口设置.单页应用程序(angluar)合并部署方式等相关问题,特将解决过 ...