A. 直接从状态(0,0)bfs, 这样一定是最小的

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=%P;for (a%=P;n;a=a*a%P,n>>=)if(n&)r=r*a%P;return r;}
ll inv(ll x){return x<=?:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=;char p=getchar();while(p<''||p>'')p=getchar();while(p>=''&&p<='')x=x*+p-'',p=getchar();return x;}
//head #ifdef ONLINE_JUDGE
const int N = 1e6+;
#else
const int N = ;
#endif int d, s;
int vis[][];
pii pre[][];
void bfs() {
queue<pii> q;
q.push(pii(,));
vis[][] = ;
while (q.size()) {
int x=q.front().x,y=q.front().y;
q.pop();
REP(i,,) if (y+i<=s) {
int xx=(x*+i)%d,yy=y+i;
if (!vis[xx][yy]) {
vis[xx][yy] = ;
pre[xx][yy]=pii(x,y);
q.push(pii(xx,yy));
}
}
}
}
void dfs2(int x, int y) {
if (x||y) {
dfs2(pre[x][y].x,pre[x][y].y);
printf("%d",y-pre[x][y].y);
}
} int main() {
scanf("%d%d", &d, &s);
bfs();
if (!vis[][s]) return puts("-1"),;
dfs2(,s),hr;
}

B.

C. 事件差分一下, 然后线段树上二分. 刚开始用map维护前k小, 结果TLE on test 77, 感觉复杂度应该对的啊...可能常数太大. 线段树写的时候要注意不仅价格和会爆$int$, 个数和也会爆.... 十分钟打完, WA了一个多小时才发现是少个$long long$

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=%P;for (a%=P;n;a=a*a%P,n>>=)if(n&)r=r*a%P;return r;}
ll inv(ll x){return x<=?:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=;char p=getchar();while(p<''||p>'')p=getchar();while(p>=''&&p<='')x=x*+p-'',p=getchar();return x;}
//head const int N = 1e6+;
int n,k,m,cnt;
ll ans;
vector<pii> s[N];
struct {ll c,s;} tr[N<<];
void update(int o, int l, int r, int p, int c) {
tr[o].c+=c,tr[o].s+=(ll)p*c;
if (l!=r) mid>=p?update(ls,p,c):update(rs,p,c);
}
ll find(int o, int l, int r, int k) {
if (tr[o].c<=k) return tr[o].s;
if (l==r) return min(tr[o].c,(ll)k)*l;
if (tr[lc].c>=k) return find(ls,k);
return tr[lc].s+find(rs,k-tr[lc].c);
}
int main() {
scanf("%d%d%d", &n, &k, &m);
int mx = ;
REP(i,,m) {
int l=rd(),r=rd(),c=rd(),p=rd();
s[l].pb(pii(p,c)), s[r+].pb(pii(p,-c));
mx = max(mx, p);
}
REP(i,,n) {
for (auto &&t:s[i]) update(,,mx,t.x,t.y);
ans += find(,,mx,k);
}
printf("%lld\n", ans);
}

F. 贪心, 11肯定要选, 01和10同时选不会产生负面, 最后从剩余的01或10,和00中选前k大与11匹配.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=%P;for (a%=P;n;a=a*a%P,n>>=)if(n&)r=r*a%P;return r;}
ll inv(ll x){return x<=?:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=;char p=getchar();while(p<''||p>'')p=getchar();while(p>=''&&p<='')x=x*+p-'',p=getchar();return x;}
//head #ifdef ONLINE_JUDGE
const int N = 1e6+;
#else
const int N = ;
#endif int n;
priority_queue<int> g[N]; int main() {
scanf("%d", &n);
int tot = , ans = ;
REP(i,,n) {
int x, y;
scanf("%d%d", &x, &y);
g[x].push(y);
if (x==) ++tot,ans+=y;
}
int sz = min(g[].size(),g[].size());
REP(i,,sz-) {
ans+=g[].top()+g[].top();
g[].pop(),g[].pop();
}
int now = g[].size()?:;
REP(i,,tot) g[now].push();
REP(i,,tot) g[].push();
REP(i,,tot) {
if (g[now].top()>g[].top()) {
ans += g[now].top();
g[now].pop();
}
else {
ans += g[].top();
g[].pop();
}
}
printf("%d\n", ans);
}

J. bitset优化

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=%P;for (a%=P;n;a=a*a%P,n>>=)if(n&)r=r*a%P;return r;}
ll inv(ll x){return x<=?:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=;char p=getchar();while(p<''||p>'')p=getchar();while(p>=''&&p<='')x=x*+p-'',p=getchar();return x;}
//head const int N = 2e5+;
int n, m, k, f[N];
char s[N];
const int N1 = , N2 = , N3 = , N4 = ;
const int N5 = , N6 = , N7 = ;
const int N8 = , N9 = , N10 = ;
bitset<N1> b1;
bitset<N2> b2;
bitset<N3> b3;
bitset<N4> b4;
bitset<N5> b5;
bitset<N6> b6;
bitset<N7> b7;
bitset<N8> b8;
bitset<N9> b9;
bitset<N10> b10;
#define solve(b) ({REP(i,1,*f) {\
b.reset();\
b.set();\
REP(j,,*f) if (j!=i) b |= b<<f[j];\
PER(j,,min(n,f[i])) {\
int t = max(,m-k+n+f[i]-j);\
if (b[n-j]) ans = min(ans, j*t);\
}\
}}) void work() {
scanf("%d%d%d%s", &n, &m, &k, s+);
REP(i,'A','Z') f[i]=;
REP(i,,k) ++f[s[i]];
if (n>m) swap(n,m);
*f = ;
REP(i,'A','Z') if (f[i]) f[++*f]=f[i];
int ans = 1e9;
if (n>N9) solve(b10);
else if (n>N8) solve(b9);
else if (n>N7) solve(b8);
else if (n>N6) solve(b7);
else if (n>N5) solve(b6);
else if (n>N4) solve(b5);
else if (n>N3) solve(b4);
else if (n>N2) solve(b3);
else if (n>N1) solve(b2);
else solve(b1);
printf("%d\n", ans);
} int main() {
int t;
scanf("%d", &t);
while (t--) work();
}

2018-2019 ICPC, NEERC, Southern Subregional Contest (codeforces 1070)的更多相关文章

  1. 2018-2019 ICPC, NEERC, Southern Subregional Contest

    目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...

  2. Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest

    2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...

  3. 2018.10.20 2018-2019 ICPC,NEERC,Southern Subregional Contest(Online Mirror, ACM-ICPC Rules)

    i207M的“怕不是一个小时就要弃疗的flag”并没有生效,这次居然写到了最后,好评=.= 然而可能是退役前和i207M的最后一场比赛了TAT 不过打得真的好爽啊QAQ 最终结果: 看见那几个罚时没, ...

  4. 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 ...

  5. 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, ...

  6. 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) Solution

    A. Find a Number Solved By 2017212212083 题意:$找一个最小的n使得n % d == 0 并且 n 的每一位数字加起来之和为s$ 思路: 定义一个二元组$< ...

  7. Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结

    第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...

  8. codeforce1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) 题解

    秉承ACM团队合作的思想懒,这篇blog只有部分题解,剩余的请前往星感大神Star_Feel的blog食用(表示男神汉克斯更懒不屑于写我们分别代写了下...) C. Cloud Computing 扫 ...

  9. 【*2000】【2018-2019 ICPC, NEERC, Southern Subregional Contest C 】Cloud Computing

    [链接] 我是链接,点我呀:) [题意] [题解] 我们可以很容易知道区间的每个位置有哪些安排可以用. 显然 我们优先用那些花费的钱比较少的租用cpu方案. 但一个方案可供租用的cpu有限. 我们可以 ...

随机推荐

  1. HDU 4738--Caocao's Bridges(重边无向图求桥)

    Caocao's Bridges Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  2. Android_(控件)Chronometer计时器

    Android Chronometer(计时器) 继承TextView,显示的是某个时间点开始以及之后的时间增加 运行截图 程序结构 package com.example.administrator ...

  3. 安装Dubbo 并且安装注册中心(Zookeeper-3.3.6)

    安装zookeeper 安装Tomcat 载dubbo-admin-2.5.4.war 进入Apache ZooKeeper官方网站进行下载,https://zookeeper.apache.org/ ...

  4. mysql索引失效问题

    1.两表关联使用的条件字段中字段的长度是否是一致的 2.两表关联使用的条件字段中字段的编码是否是一致的

  5. NOIP2010提高组真题部分整理(没有关押罪犯)

    目录 \(NOIP2010\)提高组真题部分整理 \(T1\)机器翻译: 题目背景: 题目描述: 输入输出格式: 输入输出样例: 说明: 题解: 代码: \(T2\)乌龟棋 题目背景: 题目描述: 输 ...

  6. React组件库集锦及学习视频

    [转载]https://www.rails365.net/articles/react-zui-hao-de-ui-zu-jian-ku-ji-jin 这里有一篇讨论,说了哪个才是 React 最好的 ...

  7. leetcode 11盛水最多的容器

    class Solution { public: int maxArea(vector<int>& height) { //双指针法:从最宽的容器开始计算,当更窄的容器盛水量要大于 ...

  8. Typography 字体

    Typography 字体 我们对字体进行统一规范,力求在各个操作系统下都有最佳展示效果. ¶中文字体 和畅惠风 PingFang SC 和畅惠风 Hiragino Sans GB 和畅惠风 Micr ...

  9. 【7】解决:移动端点击a链接出现蓝色边框

    [1]_blank : 浏览器总在一个新打开.未命名的窗口中载入目标文档. [2]title :  鼠标悬浮显示的文字. [3]href : 跳转到哪个链接.     a{    border: no ...

  10. Jmeter(十)负载生成器

    使用LoadRunner时, 产生负载会用到利器Load Generator, 来远程控制负载机进行测试. Jmeter也不例外, 由此可见, 工具与工具之间, 达到的目的必是相同, 只是手段不一样罢 ...