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\n",ans[i]);
57             //cout<<ans[i]<<endl;
58     }
59 
60 
61     return 0;
62 }
View Code

相关文章:

  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2021-04-18
  • 2021-06-03
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-18
  • 2021-07-31
  • 2021-08-17
  • 2022-01-10
  • 2021-06-19
  • 2021-06-18
相关资源
相似解决方案