# 10.15考试反思

### Contest2170 - 2019年10月多校联训B层测试11

T1 衣服

http://www.accoders.com/problem.php?cid=2170&pid=0

1 #include <bits/stdc++.h>
2 #define ll long long
3 #define res register
4 #define MAXN 200050
5 #define int ll
6 using namespace std;
7 int n,m,want[MAXN],color[MAXN];
8 bool vis[MAXN];
9 struct Node{
10     int a,b,val,num;
11     friend inline bool operator<(Node a,Node b){
12         if(a.val!=b.val)
13         return a.val>b.val;
14     }
15 }c[MAXN];
16 priority_queue<Node>q[4];
18 {
19     int s=0,w=1;char ch=getchar();
20     while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
21     while(ch>='0'&&ch<='9'){s=(s<<1)+(s<<3)+ch-48;ch=getchar();}
22     return s*w;
23 }
24 signed main()
25 {
27     for(res int i=1;i<=n;i++) c[i].val=read(),c[i].num=i;
28     for(res int i=1;i<=n;i++) c[i].a=read();
29     for(res int i=1;i<=n;i++) c[i].b=read();
31     for(res int i=1;i<=n;i++){
32         q[c[i].a].push(c[i]);
33         q[c[i].b].push(c[i]);
34     }
35     for(res int i=1;i<=m;i++) want[i]=read();
36     for(res int i=1;i<=m;i++){
37         if(q[want[i]].empty()) {cout<<"-1"<<" ";continue;}
38         while(vis[q[want[i]].top().num]) q[want[i]].pop();
39         printf("%lld ",q[want[i]].top().val);
40         vis[q[want[i]].top().num]=1;
41         q[want[i]].pop();
42     }
43     return 0;
44 }
View Code

T2 分段

http://www.accoders.com/problem.php?cid=2170&pid=1

T3 拜访

http://www.accoders.com/problem.php?cid=2170&pid=2

1 #include <bits/stdc++.h>
2 #define ll long long
3 #define res register
4 #define MAXN 100050
5 #define int ll
6 using namespace std;
8 bool vis[MAXN],ju;
9 struct Node{
10     int to,nxt,dis;
11 }g[MAXN];
12 inline void add(int u,int v,int dis){
13     static int top=0;
16 }
17 deque<int>q;
18 inline void spfa(){
19     memset(diss,0x7f7f7f,sizeof(diss));
20     diss[1]=0;q.push_front(1);
21     while(!q.empty()){
22         int now=q.front();q.pop_front();vis[now]=0;
23         for(res int i=head[now];i;i=g[i].nxt){
24             int to=g[i].to,dis2=g[i].dis;
25             if(diss[to]>diss[now]+dis2){
26                 diss[to]=diss[now]+dis2;
27                 if(!vis[to]){
28                     vis[to]=1;if(q.empty()||diss[to]>diss[q.front()])q.push_back(to);
29                     else q.push_front(to);
30                 }
31             }
32         }
33     }
34
35 }
37 {
38     int s=0,w=1;char ch=getchar();
39     while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
40     while(ch>='0'&&ch<='9'){s=(s<<1)+(s<<3)+ch-48;ch=getchar();}
41     return s*w;
42 }
43 signed main()
44 {
46     for(res int i=1;i<=m;i++){
49     }
50     for(res int i=1;i<=as;i++){
52         if(op==1) {
53             if(ju) printf("%lld\n",diss[x]>=0x7f7f7f?-1:diss[x]);
54             else {spfa();printf("%lld\n",diss[x]>=0x7f7f7f?-1:diss[x]);ju=1;}
55         }
56         else{
57             for(res int i=1;i<=x;i++)
59         }
60     }
61     return 0;
62 }
View Code

posted @ 2019-11-12 14:56  Lbmttw_lx  阅读(129)  评论(0编辑  收藏  举报