2018 hdu 多校 第二场

因为3点半才来(其实是3点50,刚刚到酒店就开始了= =队友也是一个那时刚刚睡醒= =

1004 小甜甜

全部yes就好了

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 #include <cmath>
 5 #include <vector>
 6 #include <queue>
 7 #include <set>
 8 #include <map>
 9 #include <string>
10 #include <string.h>
11 #include <stdlib.h>
12 #include <time.h>
13 #include <climits>
14 
15 using namespace std;
16 
17 int main(){
18     int n;
19     while (scanf("%d",&n)!=EOF) puts("Yes");
20     return 0;
21 }
View Code

1005 BPM136

  1 /* ***********************************************
  2 Author        :BPM136
  3 Created Time  :2018/7/26 22:58:35
  4 File Name     :1005.cpp
  5 ************************************************ */
  6 
  7 #include<iostream>
  8 #include<cstdio>
  9 #include<algorithm>
 10 #include<cstdlib>
 11 #include<cmath>
 12 #include<cstring>
 13 #include<iomanip>
 14 #include<bitset>
 15 #include<queue>
 16 #include<ctime>
 17 #include<set>
 18 #include<map>
 19 #include<vector>
 20 #include<cassert>
 21 #include<functional>
 22 #define pb push_back
 23 #define popb pop_back
 24 #define MID ((l+r)>>1)
 25 #define LSON (k<<1)
 26 #define RSON (k<<1|1)
 27 #define get(a,i) ((a)&(1<<(i-1)))
 28 #define PAU putchar(32)
 29 #define ENT putchar(10)
 30 #define clr(a,b) memset(a,b,sizeof(a))
 31 #define rep(_i,_a,_b) for(int _i=(_a);_i<(_b);_i++)
 32 #define down(_i,_a,_b) for(int _i=(_a);_i>(_b);_i--)
 33 #define FOR(_i,_b) for(int _i=1;_i<=(_b);_i++)
 34 #define efo(_i,_a) for(int _i=last[(_a)];_i!=0;_i=e[_i].next)
 35 #define Remax(a,b) if(b>a) a=b;
 36 #define Remin(a,b) if(b<a) a=b;
 37 #define filein(x) freopen(#x".in","r",stdin)
 38 #define fileout(x) freopen(#x".out","w",stdout)
 39 #define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
 40 #define mkd(x) freopen(#x".in","w",stdout);
 41 #define setlargestack(x) int _SIZE=x<<20;char *_PPP=(char*)malloc(size)+_SIZE;__asm__("movl %0, %%esp\n" :: "r"(_PPP));
 42 #define END system("pause")
 43 #define read2(a,b) read(a),read(b)
 44 #define read3(a,b,c) read(a),read(b),read(c)
 45 #define readg(_x1,_y1,_x2,_y2) read(_x1),read(_y1),read(_x2),read(_y2)
 46 using namespace std;
 47 
 48 typedef long long ll;
 49 typedef double DB;
 50 typedef long double LD;
 51 typedef unsigned int  UI;
 52 typedef unsigned long long ULL;
 53 typedef vector<int> VI;
 54 typedef set<int> SI;
 55 typedef set<int , greater<int> > SIG;
 56 typedef map<int, int > MII;
 57 typedef map<int, int, greater<int> > MIIG;
 58 
 59 namespace fastIO{  
 60     #define BUF_SIZE 100000  
 61     #define OUT_SIZE 100000  
 62     //fread->read  
 63     bool IOerror=0;  
 64     inline char nc(){  
 65         static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;  
 66         if (p1==pend){  
 67             p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);  
 68             if (pend==p1){IOerror=1;return -1;}  
 69             //{printf("IO error!\n");system("pause");for (;;);exit(0);}  
 70         }  
 71         return *p1++;  
 72     }  
 73     inline bool blank(char ch){return ch==32||ch==10||ch==13||ch==9;}  
 74     inline bool enter(char ch){return ch==10||ch==13;}
 75     inline void read(int &x){  
 76         bool sign=0; char ch=nc(); x=0;  
 77         for (;blank(ch);ch=nc());  
 78         if (IOerror)return;  
 79         if (ch==45)sign=1,ch=nc();  
 80         for (;ch>=48&&ch<=57;ch=nc())x=x*10+ch-48;  
 81         if (sign)x=-x;  
 82     }  
 83     inline void read(ll &x){  
 84         bool sign=0; char ch=nc(); x=0;  
 85         for (;blank(ch);ch=nc());  
 86         if (IOerror)return;  
 87         if (ch==45)sign=1,ch=nc();  
 88         for (;ch>=48&&ch<=57;ch=nc())x=x*10+ch-48;  
 89         if (sign)x=-x;  
 90     }  
 91     inline void read(double &x){  
 92         bool sign=0; char ch=nc(); x=0;  
 93         for (;blank(ch);ch=nc());  
 94         if (IOerror)return;  
 95         if (ch==45)sign=1,ch=nc();  
 96         for (;ch>=48&&ch<=57;ch=nc())x=x*10+ch-48;  
 97         if (ch==46){  
 98             double tmp=1; ch=nc();  
 99             for (;ch>=48&&ch<=57;ch=nc())tmp/=10.0,x+=tmp*(ch-48);  
100         }  
101         if (sign)x=-x;  
102     }  
103     inline void read(char *s){  
104         char ch=nc();  
105         for (;blank(ch);ch=nc());  
106         if (IOerror)return;  
107         for (;!blank(ch)&&!IOerror;ch=nc())*s++=ch;  
108         *s=0;  
109     }  
110     inline void read(char *s,bool f) {
111         char ch=nc();
112         for (;blank(ch);ch=nc());
113         if(IOerror)return;
114         for(;!enter(ch)&&!IOerror;ch=nc())*s++=ch;
115         *s=0;
116     }
117     inline void read(char &c){  
118         for (c=nc();blank(c);c=nc());  
119         if (IOerror){c=-1;return;}  
120     } 
121 #undef OUT_SIZE  
122 #undef BUF_SIZE  
123 }; using namespace fastIO;
124 
125 int a[2500][2500];
126 
127 int main() {
128     puts("2000");
129     clr(a,0);
130     int MOD = 47;
131     rep(i,0,MOD) rep(j,0,MOD) rep(k,0,MOD) {
132         a[i*MOD+j][k*MOD+(j*k+i)%MOD]=1;
133     }
134     rep(i,0,2000) {
135         rep(j,0,2000) printf("%d",a[i][j]);
136         printf("\n");
137     }
138     return 0;
139 }
View Code

1007 小洛洛

线段树暴力pushdown就好了,维护还需要几步就需要+1了

  1 #include <cstdio>
  2 #include <cstdlib>
  3 #include <cstring>
  4 #include <cmath>
  5 #include <algorithm>
  6 #include <vector>
  7 using namespace std;
  8 
  9 const int N = 100002;
 10 int perm[N];
 11 
 12 struct T_ {
 13     int s, pos;
 14     int mark;
 15     int sum, nxt;
 16     T_ *l, *r;
 17 
 18     T_() {}
 19     T_(int _pos) {
 20         s = 1;
 21         pos = _pos;
 22         mark = sum = 0;
 23         nxt = perm[pos];
 24         l = r = nullptr;
 25     }
 26     T_(T_ *_l, T_ *_r) {
 27         l = _l, r = _r;
 28         s = l->s + r->s;
 29         pos = l->pos;
 30         mark = 0;
 31         sum = l->sum + r->sum;
 32         nxt = min(l->nxt, r->nxt);
 33     }
 34 
 35     T_ *app_(int x) {
 36         if(!l) { // leaf
 37             if(x < nxt)
 38                 nxt -= x;
 39             else {
 40                 sum += (x - nxt) / perm[pos] + 1;
 41                 nxt = perm[pos] - (x - nxt) % perm[pos];
 42             }
 43         } else {
 44             mark += x;
 45             if(x >= nxt)
 46                 down_();
 47             else
 48                 nxt -= x;
 49         }
 50         return this;
 51     }
 52 
 53     T_ down_() {
 54         if(mark)
 55             return *this = T_(l->app_(mark), r->app_(mark));
 56         return *this;
 57     }
 58 } ss[N * 4], *sp;
 59 
 60 T_ *make_(int l, int r) {
 61     int m = l + (r - l) / 2;
 62     T_ *c = sp++;
 63     return r - l == 1 ? new(c) T_(l) : new(c) T_(make_(l, m), make_(m, r));
 64 }
 65 
 66 template<typename F>
 67 T_ *seg_(T_ *c, int l, int r, F f) {
 68     if(l <= 0 && r >= c->s)
 69         return f(c), c;
 70     c->down_();
 71     int m = c->s / 2;
 72     *c = T_(
 73         l < m ? seg_(c->l, l, r, f) : c->l,
 74         m < r ? seg_(c->r, l - m, r - m, f) : c->r
 75     );
 76     return c;
 77 }
 78 
 79 int main() {
 80     int n, q;
 81     while(scanf("%d%d", &n, &q) != EOF) {
 82         for(int i = 0; i < n; ++i)
 83             scanf("%d", perm + i);
 84         sp = ss;
 85         T_ *rt = make_(0, n);
 86         while(q--) {
 87             char op[8];
 88             int l, r;
 89             scanf("%s%d%d", op, &l, &r);
 90             --l;
 91             if(op[0] == 'q') {
 92                 int x = 0;
 93                 seg_(rt, l, r, [&](T_ *c){x += c->sum;});
 94                 printf("%d\n", x);
 95             } else
 96                 seg_(rt, l, r, [](T_ *c){c->app_(1);});
 97         }
 98     }
 99     return 0;
100 }
View Code

1010 小洛洛

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 #include <cmath>
 5 #include <vector>
 6 #include <queue>
 7 #include <set>
 8 #include <map>
 9 #include <string>
10 #include <string.h>
11 #include <stdlib.h>
12 #include <time.h>
13 #include <climits>
14 
15 using namespace std;
16 
17 const int maxN=1e5+7;
18 
19 typedef pair<int,int> pii;
20 
21 int n;
22 int a[maxN];
23 int h[maxN];
24 pii p[maxN];
25 
26 int c[maxN];
27 
28 int Hash(int x){
29     return lower_bound(h+1,h+n+1,x)-h;
30 }
31 
32 int lowbit(int x){
33     return x&(-x);
34 }
35 
36 int query(int x){
37     int ret=0;
38     while (x){
39         ret+=c[x];
40         x-=lowbit(x);
41     }
42     return ret;
43 }
44 
45 void add(int x){
46     while (x<=n){
47         c[x]++;
48         x+=lowbit(x);
49     }
50 }
51 
52 void work(){
53     int x,y;
54     scanf("%d%d",&x,&y);
55 
56     for (int i=1;i<=n;i++) scanf("%d",&a[i]),h[i]=a[i];
57     sort(h+1,h+n+1);
58 
59     for (int i=1;i<=n;i++) {
60         p[i].first=Hash(a[i]);
61         p[i].second=i;
62         c[i]=0;
63     }    
64 
65     sort(p+1,p+n+1);
66 
67     long long ans=0;
68 
69     for (int i=n;i>0;i--){
70         ans+=query(p[i].second);
71         add(p[i].second);
72     }
73 
74     printf("%lld\n",1LL*min(x,y)*ans);
75 }
76 
77 int main(){
78     while (scanf("%d",&n)!=EOF) work();
79     return 0;
80 }
View Code

猜你喜欢

转载自www.cnblogs.com/MyGirlfriends/p/9375046.html