bc#27做题笔记

rating掉的哗哗的T^T

1001:水题

1002:水题,但是题目看错了+手速太捉急

     看一下样例解释就会知道,实际上第i个人只能坐第i辆公交车。= =好反人类

     这样的话题目就简单了许多.....

1003:想出了相邻元素相除再模式匹配的方法......无奈第二题卡题ing+不会AC自动机,放弃

码农模拟题手速还是要练。要有gx大神那种手速才行orz

附1002 code:

以后养成尽量用scanf、printf的习惯....白TLE了一次

 1 #include <iostream>
 2 #include <cstring>
 3 #include <cstdio>
 4 using namespace std;
 5 #define mmx 100010
 6 #define LL  long long
 7 
 8 struct PER
 9 {
10     int x,y,dir;
11 }p[mmx];
12 
13 LL  a[mmx],A[mmx],ans[mmx];
14 int T,n,m;
15 
16 int main()
17 {
18     cin>>T;
19     while (T--)
20     {
21         cin>>n>>m;
22         memset(A,0,sizeof(A));
23         for (int i=1;i<=n-1;i++)
24         {
25             //cin>>a[i];               //a[i]:i->i+1
26             scanf("%d",&a[i]);
27             A[i+1]=A[i]+a[i];        //A[i]:1-->i       A[i]-A[j]: j-->i
28         }
29 
30         for (int i=1;i<=m;i++)
31         {
32             //cin>>p[i].x>>p[i].y;      //person i : x->y
33             scanf("%d%d",&p[i].x,&p[i].y);
34             if (p[i].y>p[i].x)  p[i].dir=1; else p[i].dir=2;
35             int tx=p[i].x,ty=p[i].y,pos=((i-1)%n)+1;
36             if (p[i].dir==1)        //  -->
37             {
38                 if (tx==pos)
39                     ans[i]=A[ty]-A[tx];
40                 else if (pos>tx)
41                     ans[i]=A[n]-A[pos]+A[n]+A[ty];
42                 else
43                     ans[i]=A[ty]-A[pos];
44             }
45             else                    //  <--
46             {
47                 if (pos==tx)
48                     ans[i]=A[n]-A[pos]+A[n]-A[ty];
49                 else if (pos<tx)
50                     ans[i]=A[n]-A[pos]+A[n]-A[ty];
51                 else
52                     ans[i]=A[n]-A[pos]+A[n]-A[ty];
53             }
54         }
55         for (int i=1;i<=m;i++)
56             printf("%I64d
",ans[i]);
57             //cout<<ans[i]<<endl;
58     }
59 
60 
61     return 0;
62 }
View Code

1003半成品code,以后刷到自动机的时候再填坑

 1 #include <iostream>
 2 using namespace std;
 3 
 4 
 5 int main()
 6 {
 7     cin>>T;
 8     while (T--)
 9     {
10         cin>>n>>m;
11         for (int i=0; i<n; i++)
12             scanf("%d",&a[i]);      //Alice
13         for (int i=n-1;i>=1;i--)
14         {
15             r[i-1]=a[i]/a[i-1];
16         }
17         n--;
18         r[n]=0;
19         //r[0...n-1]:text
20 
21         long long ans=0;
22         for(int i=1;i<=m;i++)
23         {
24             cin>>p;
25             for (int j=0;j<p;j++)
26                 cin>>a[j];
27             if (p==1)
28             {
29                 ans+=n+1;
30             }
31             else
32             {
33                 for (int j=p-1;j>=1;j--)
34                     b[j-1]=a[j]/a[j-1];
35                 p--;
36                 b[p]=0;
37                 //b[0..p-1]:pattern
38             }
39         }
40 
41 
42     }
43 }
View Code
原文地址:https://www.cnblogs.com/pdev/p/4246886.html