题还没补完

以下是牢骚:删了

现在只有六个。。。太恐怖了,我发现四星场我连300人的题都不会啊。

C:最短路加一维状态就好了叭。。嗯,一开始没看到输出的那句话 那个  "."也要输出,然后n,m看反了,这反人类啊这nm。

  1. #include <bits/stdc++.h>
  2. #define mk(a,b) make_pair(a,b)
  3. #define pii pair<int,int>
  4. using namespace std;
  5. typedef long long ll;
  6. struct node{
  7. int u,t,p;
  8. bool operator<(const node&rhs)const {
  9. return p>rhs.p;
  10. }
  11. };
  12. int x,n,m,l;
  13. vector<int>g[];
  14. int t[],p[],dis[][];
  15. void Dijkstra(){
  16. for(int i=;i<=n;i++)for(int j=;j<=x;j++)dis[i][j]=;
  17. if(t[]>x)return;
  18. dis[][t[]]=p[];
  19. priority_queue<node>Q;
  20. Q.push(node{,t[],p[]});
  21. while (!Q.empty()){
  22. node fr = Q.top();Q.pop();
  23. if(dis[fr.u][fr.t]<fr.p)continue;
  24. if(fr.t+t[fr.u]<=x&&fr.p+p[fr.u]<dis[fr.u][fr.t+t[fr.u]]){
  25. dis[fr.u][fr.t+t[fr.u]]=fr.p+p[fr.u];
  26. Q.push(node{fr.u,fr.t+t[fr.u],fr.p+p[fr.u]});
  27. }
  28. for(auto u:g[fr.u]){
  29. if(fr.t+t[u]+l<=x&&fr.p+p[u]<dis[u][fr.t+t[u]+l]) {
  30. dis[u][fr.t+t[u]+l]=fr.p+p[u];
  31. Q.push(node{u, fr.t + t[u] + l, fr.p + p[u]});
  32. }
  33. }
  34. }
  35. }
  36. int main(){
  37. ios::sync_with_stdio(false);
  38. cin>>x>>n>>m>>l;
  39. int a,b;
  40. for(int i=;i<=m;i++){
  41. cin>>a>>b;
  42. g[a].push_back(b);
  43. g[b].push_back(a);
  44. }
  45. for(int i=;i<=n;i++){
  46. cin>>t[i]>>p[i];
  47. }
  48. Dijkstra();
  49. if(dis[][x]==)cout<<"It is a trap."<<endl;
  50. else cout<<dis[][x]<<endl;
  51. }

D:签到,我写的很傻逼

  1. #include <bits/stdc++.h>
  2. #define mk(a,b) make_pair(a,b)
  3. #define pii pair<int,int>
  4. using namespace std;
  5. typedef long long ll;
  6. string s1,s2,s;
  7. int n,m,cnt=,vis[];
  8. map<string,int>mp;
  9. vector<int>g[];
  10. set<int> st[];
  11. void dfs(int v){
  12. st[v].insert(v);
  13. for(auto u:g[v]){
  14. dfs(u);
  15. for(auto tmp:st[u])
  16. st[v].insert(tmp);
  17. }
  18. }
  19. int main(){
  20. ios::sync_with_stdio(false);
  21. cin>>n>>m;
  22. while (n--){
  23. cin>>s1>>s>>s>>s>>s2;
  24. if(!mp.count(s1))mp[s1]=cnt++;
  25. if(!mp.count(s2))mp[s2]=cnt++;
  26. g[mp[s2]].push_back(mp[s1]);
  27. }
  28. for(int i=;i<cnt;i++){
  29. if(!vis[i])
  30. dfs(i);
  31. }
  32. while (m--){
  33. cin>>s1>>s>>s>>s>>s2;
  34. if(!mp.count(s1)||!mp.count(s2)){
  35. cout<<"Pants on Fire"<<endl;
  36. } else{
  37. if(st[mp[s2]].count(mp[s1])){
  38. cout<<"Fact"<<endl;
  39. } else if(st[mp[s1]].count(mp[s2])){
  40. cout<<"Alternative Fact"<<endl;
  41. } else{
  42. cout<<"Pants on Fire"<<endl;
  43. }
  44. }
  45. }
  46. }

G:现学的那个什么皮克公式。好神奇啊!虽然不知道为什么。然后仔细读题会发现他给你的点是按顺序的。算一下叉积就完了。可以百度 皮克公式呀qwq

  1. #include <bits/stdc++.h>
  2. #define mk(a,b) make_pair(a,b)
  3. #define pii pair<int,int>
  4. using namespace std;
  5. typedef long long ll;
  6. int n;
  7. struct point{
  8. ll x,y;
  9. }p[];
  10. ll cross(point k1,point k2){return k1.x*k2.y-k1.y*k2.x;}
  11. ll gcd(ll a,ll b){
  12. a=abs(a);b=abs(b);
  13. if(a==)return b;
  14. if(b==)return a;
  15. return __gcd(a,b);
  16. }
  17. int main(){
  18. //ios::sync_with_stdio(false);
  19. scanf("%d",&n);
  20. for(int i=;i<n;i++)
  21. scanf("%lld%lld",&p[i].x,&p[i].y);
  22. ll S=,cnt=;
  23. for(int i=;i<n;i++){
  24. S+=cross(p[i],p[(i+)%n]);
  25. }
  26. S/=;
  27. S=abs(S);
  28. for(int i=;i<n;i++){
  29. cnt+=gcd(p[i].x-p[(i+)%n].x,p[i].y-p[(i+)%n].y);
  30. }
  31. ll a = S-cnt/+;
  32. printf("%lld\n",a);
  33. }
  34. /**
  35. 4
  36. 0 0
  37. 0 10
  38. 10 10
  39. 10 0
  40.  
  41. 4
  42. 0 3
  43. 3 0
  44. 0 -1
  45. -1 0
  46. */

F:哇上来我一看,这直接枚举不就完了吗!TLE ON TEST 8。说好的玄学复杂度呢呜呜呜  自闭。 后来想到会有大量重复的过程,,但是我学艺不精,写的最大流,就不会改了。。昨天看了题解!

哇!二分图匹配,然后每个点再做两次增广!用另外一个数组把一开始的存下来。草!这题竟该死的巧妙。匈牙利大法好哇。

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N = 1e5+;
  4. const int INF = 0x3f;
  5. struct Edge{
  6. int u,v,nxt;
  7. Edge(int u=,int v=,int nxt=):u(u),v(v),nxt(nxt){}
  8. }edge[*N];
  9. int n,m,k,cnt;
  10. int head[N],d[N],c[N];
  11. void addEdge(int u,int v){
  12. edge[++cnt]=Edge(u,v,head[u]);
  13. head[u]=cnt;
  14. }
  15. int match[N],vis[N],tmp[N];
  16. bool dfs(int u){
  17. for(int i=head[u];~i;i=edge[i].nxt){
  18. int v = edge[i].v;
  19. if(vis[v])continue;
  20. vis[v]=;
  21. if(match[v]==-||dfs(match[v])){
  22. match[v]=u;
  23. return true;
  24. }
  25. }
  26. return false;
  27. }
  28. void init(){
  29. memset(head,-, sizeof(head));
  30. cnt=;
  31. }
  32. int main(){
  33. ios::sync_with_stdio(false);
  34. init();
  35. scanf("%d%d%d",&n,&m,&k);
  36. int u,v;
  37. for(int i=;i<=k;i++){
  38. scanf("%d%d",&u,&v);
  39. addEdge(u,v);
  40. }
  41. int mx=;
  42. memset(match,-, sizeof(match));
  43. for(int i=;i<=n;i++){
  44. memset(vis,, sizeof(vis));
  45. if(dfs(i))mx++;
  46. }
  47. memcpy(tmp,match,sizeof(match));
  48. int ans =;
  49. for(int i=;i<=n;i++){
  50. int num=;
  51. while (dfs(i)&&num<){
  52. memset(vis,, sizeof(vis));
  53. num++;
  54. }
  55. ans=max(ans,num);
  56. memcpy(match,tmp, sizeof(tmp));
  57. }
  58. printf("%d\n",ans+mx);
  59. }

I:签到

  1. #include <bits/stdc++.h>
  2. #define mk(a,b) make_pair(a,b)
  3. #define pii pair<int,int>
  4. using namespace std;
  5. typedef long long ll;
  6. const int N = 3e5+;
  7. int n,m;
  8. int a[N],dp[N][];
  9. int main(){
  10. ios::sync_with_stdio(false);
  11. cin>>n>>m;
  12. for(int i=;i<=n;i++)cin>>a[i];
  13. for(int i=m+;i<=n;i++){
  14. dp[i][]=max(dp[i-m][],dp[i-m][])+a[i];
  15. dp[i][]=max(dp[i-][],dp[i-][]);
  16. }
  17. cout<<max(dp[n][],dp[n][]);
  18. }

K:签到

  1. #include <bits/stdc++.h>
  2. #define mk(a,b) make_pair(a,b)
  3. #define pii pair<int,int>
  4. using namespace std;
  5. typedef long long ll;
  6. int n,d,k;
  7. struct Node{
  8. string s;
  9. int c;
  10. bool operator < (const Node& a)const {
  11. return c<a.c;
  12. }
  13. };
  14. priority_queue<Node> q;
  15. vector<string>ans;
  16. int main(){
  17. ios::sync_with_stdio(false);
  18. cin>>n>>d>>k;
  19. string s;int c;
  20. while (n--){
  21. cin>>s>>c;
  22. q.push(Node{s,c});
  23. }
  24. int sum=;
  25. while (!q.empty()&&sum<d){
  26. sum+=q.top().c;
  27. ans.push_back(q.top().s);
  28. q.pop();
  29. }
  30. if(ans.size()>k||sum<d){
  31. cout<<"impossible"<<endl;
  32. } else{
  33. cout<<ans.size()<<endl;
  34. for(auto s:ans){
  35. cout<<s<< ", YOU ARE FIRED!"<<endl;
  36. }
  37. }
  38. }

gym 101873的更多相关文章

  1. gym/101873/GCPC2017

    题目链接:https://codeforces.com/gym/101873 C. Joyride 记忆化搜索形式的dp #include <algorithm> #include < ...

  2. Gym 101873F Plug It In(二分图匹配)

    题目链接:http://codeforces.com/gym/101873/problem/F 题意:有n个插孔,m个机器,和一个插板,一个插孔可以连接一个机器,插板可以使一个插孔连接三个机器,找到最 ...

  3. Gym 101873C - Joyride - [最短路变形][优先队列优化Dijkstra]

    题目链接:http://codeforces.com/gym/101873/problem/C 题意: 这是七月的又一个阳光灿烂的日子,你决定和你的小女儿一起度过快乐的一天.因为她真的很喜欢隔壁镇上的 ...

  4. Gym 101873D - Pants On Fire - [warshall算法求传递闭包]

    题目链接:http://codeforces.com/gym/101873/problem/D 题意: 给出 $n$ 个事实,表述为 "XXX are worse than YYY" ...

  5. Gym 101873G - Water Testing - [皮克定理]

    题目链接:http://codeforces.com/gym/101873/problem/G 题意: 在点阵上,给出 $N$ 个点的坐标(全部都是在格点上),将它们按顺序连接可以构成一个多边形,求该 ...

  6. Gym 101873I - Uberwatch - [DP]

    题目链接:http://codeforces.com/gym/101873/problem/I 题意: 给出 $n(1 \le n \le 300000)$ 个单位时间,每个单位时间给出一个 $x_i ...

  7. Gym 101873K - You Are Fired - [贪心水题]

    题目链接:http://codeforces.com/gym/101873/problem/K 题意: 现在给出 $n(1 \le n \le 1e4)$ 个员工,最多可以裁员 $k$ 人,名字为 $ ...

  8. codeforces gym #101873B. Buildings(Polya定理)

    参考博客: https://blog.csdn.net/liangzhaoyang1/article/details/72639208 题目链接: https://codeforces.com/gym ...

  9. Joyride (spaf)

    题目链接:https://codeforces.com/gym/101873/problem/C spaf的复杂度有点迷,按道理来说,一个简单的spaf在这题的复杂度是1e9,所以不敢写,然后用优先队 ...

随机推荐

  1. Android定制:修改开机启动画面

    转自:https://blog.csdn.net/godiors_163/article/details/72529210 引言 Android系统在按下开机键之后就会进入启动流程,这个过程本身需要一 ...

  2. Linux脚本程序

    #!/bin/bash # array-ops.sh: 数组更多有趣的用法. array=( zero one two three four five ) # 元素 ]} # zero } # zer ...

  3. C# Task ContinueWith的实现

    看了上一篇C# Task 是什么?返回值如何实现? Wait如何实现 我们提到FinishContinuations方法中会调用TaskContinuation实例,那么我们的ContinueWith ...

  4. [Python设计模式] 第17章 程序中的翻译官——适配器模式

    github地址:https://github.com/cheesezh/python_design_patterns 适配器模式 适配器模式,将一个类的接口转换成客户希望的另外一个接口.Adapte ...

  5. Hadoop小文件存储方案

    原文地址:https://www.cnblogs.com/ballwql/p/8944025.html HDFS总体架构 在介绍文件存储方案之前,我觉得有必要先介绍下关于HDFS存储架构方面的一些知识 ...

  6. [转]如何实现一个malloc

    任何一个用过或学过C的人对malloc都不会陌生.大家都知道malloc可以分配一段连续的内存空间,并且在不再使用时可以通过free释放掉.但是,许多程序员对malloc背后的事情并不熟悉,许多人甚至 ...

  7. 初识go的tomb包

    在分析github.com/hpcloud/tail 这个包的源码的时候,发现这个包里用于了一个另外一个包,自己也没有用过,但是这个包在tail这个包里又起来非常大的作用 当时并没有完全弄明白这个包的 ...

  8. Delphi调用java so

    package hardware.print; public class printer { static public native int Open(); } jni导出的函数是 Java_har ...

  9. 流媒体之HLS——综述

    [时间:2018-01] [状态:Open] [关键词:流媒体,stream,HLS] 0 HLS背景及初衷 HLS是由苹果公司发起的流媒体网络传输协议,可参考rfc8261 HTTP Live St ...

  10. Object type TYPE failed to create with error

    ORA-39083: Object type TYPE failed to create with error: ORA-02304: invalid object identifier litera ...