2017 多校系列 2

来源:互联网 发布:python and 编辑:程序博客网 时间:2024/06/06 08:43

Is Derek lying?

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 325    Accepted Submission(s): 196


Problem Description
Derek and Alfia are good friends.Derek is Chinese,and Alfia is Austrian.This summer holiday,they both participate in the summer camp of Borussia Dortmund.During the summer camp,there will be fan tests at intervals.The test consists of N choice questions and each question is followed by three choices marked “A” “B” and “C”.Each question has only one correct answer and each question is worth 1 point.It means that if your answer for this question is right,you can get 1 point.The total score of a person is the sum of marks for all questions.When the test is over,the computer will tell Derek the total score of him and Alfia.Then Alfia will ask Derek the total score of her and he will tell her: “My total score is X,your total score is Y.”But Derek is naughty,sometimes he may lie to her. Here give you the answer that Derek and Alfia made,you should judge whether Derek is lying.If there exists a set of standard answer satisfy the total score that Derek said,you can consider he is not lying,otherwise he is lying.
 

Input
The first line consists of an integer T,represents the number of test cases.

For each test case,there will be three lines.

The first line consists of three integers N,X,Y,the meaning is mentioned above.

The second line consists of N characters,each character is “A” “B” or “C”,which represents the answer of Derek for each question.

The third line consists of N characters,the same form as the second line,which represents the answer of Alfia for each question.

Data Range:1N80000,0X,YN,Ti=1N300000
 

Output
For each test case,the output will be only a line.

Please print “Lying” if you can make sure that Derek is lying,otherwise please print “Not lying”.
 

Sample Input
23 1 3AAAABC5 5 0ABCBCACBCB
 

Sample Output
Not lyingLying
 

Source
2017 Multi-University Training Contest - Team 2
 

Recommend
liuyiding

题意:一开始给你T个样例,每个样例N个问题,两人得分分别为x,y,接下来两行是两人的答案,判断是否说谎。

ac code:
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cstdlib>#include <cmath>#include <vector>#include <list>#include <deque>#include <queue>#include <iterator>#include <stack>#include <map>#include <set>#include <algorithm>#include <cctype>using namespace std;#define si1(a) scanf("%d",&a)#define si2(a,b) scanf("%d%d",&a,&b)#define sd1(a) scanf("%lf",&a)#define sd2(a,b) scanf("%lf%lf",&a,&b)#define ss1(s)  scanf("%s",s)#define pi1(a)    printf("%d\n",a)#define pi2(a,b)  printf("%d %d\n",a,b)#define mset(a,b)   memset(a,b,sizeof(a))#define forb(i,a,b)   for(int i=a;i<b;i++)#define ford(i,a,b)   for(int i=a;i<=b;i++)typedef long long LL;const int N=1100001;const int M=6666666;const int INF=0x3f3f3f3f;const double PI=acos(-1.0);const double eps=1e-7;const int mod = 1e9+7;char s1[80003];char s2[80003];int main(){    int T;    si1(T);    while(T--)    {        int n,x,y;        si1(n);        si2(x,y);        scanf("%s%s",s1,s2);        int coun=0;        int len=strlen(s1);        for(int i=0;i<len;i++)        {            if(s1[i]==s2[i])                coun++;        }        int cha=n-coun;        if(coun>x||y<coun)//假设相同答案的都是做对的        {            int tmp=min(x,y);            x-=tmp;            y-=tmp;        }        else        {            x-=coun;            y-=coun;        }        if(x+y>cha)        {            printf("Lying\n");        }        else        {            printf("Not lying\n");        }    }    return 0;}


Maximum Sequence

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 439    Accepted Submission(s): 236


Problem Description
Steph is extremely obsessed with “sequence problems” that are usually seen on magazines: Given the sequence 11, 23, 30, 35, what is the next number? Steph always finds them too easy for such a genius like himself until one day Klay comes up with a problem and ask him about it.

Given two integer sequences {ai} and {bi} with the same length n, you are to find the next n numbers of {ai}: an+1a2n. Just like always, there are some restrictions on an+1a2n: for each number ai, you must choose a number bk from {bi}, and it must satisfy ai≤max{aj-j│bk≤j<i}, and any bk can’t be chosen more than once. Apparently, there are a great many possibilities, so you are required to find max{2nn+1ai} modulo 109+7 .

Now Steph finds it too hard to solve the problem, please help him.
 

Input
The input contains no more than 20 test cases.
For each test case, the first line consists of one integer n. The next line consists of n integers representing {ai}. And the third line consists of n integers representing {bi}.
1≤n≤250000, n≤a_i≤1500000, 1≤b_i≤n.
 

Output
For each test case, print the answer on one line: max{2nn+1ai} modulo 109+7。
 

Sample Input
48 11 8 53 1 4 2
 

Sample Output
27
Hint
For the first sample:1. Choose 2 from {bi}, then a_2…a_4 are available for a_5, and you can let a_5=a_2-2=9; 2. Choose 1 from {bi}, then a_1…a_5 are available for a_6, and you can let a_6=a_2-2=9;
 

Source
2017 Multi-University Training Contest - Team 2
 

Recommend
liuyiding   |   We have carefully selected several similar problems for you:  6055 6054 6053 6052 6051 

题解:区间求和一般用线段树(但是我没用…)维护了一个最大数

ac code:
   . 14:38:28#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cstdlib>#include <cmath>#include <vector>#include <list>#include <deque>#include <queue>#include <iterator>#include <stack>#include <map>#include <set>#include <algorithm>#include <cctype>using namespace std;#define si1(a) scanf("%d",&a)#define si2(a,b) scanf("%d%d",&a,&b)#define sd1(a) scanf("%lf",&a)#define sd2(a,b) scanf("%lf%lf",&a,&b)#define ss1(s)  scanf("%s",s)#define pi1(a)    printf("%d\n",a)#define pi2(a,b)  printf("%d %d\n",a,b)#define mset(a,b)   memset(a,b,sizeof(a))#define forb(i,a,b)   for(int i=a;i<b;i++)#define ford(i,a,b)   for(int i=a;i<=b;i++)typedef long long LL;const int N=1100001;const int M=6666666;const int INF=0x3f3f3f3f;const double PI=acos(-1.0);const double eps=1e-7;const int mod = 1e9+7;int n;int b[260000];LL sum[260000];bool vis[260000];struct node{    int index,cnt;}a[260000];bool cmp(node x,node y){    return x.cnt>y.cnt;}int main(){    while (~si1(n))    {        for(int i=1;i<=n;i++)        {            si1(a[i].cnt);            a[i].index=i;            a[i].cnt-=i;            vis[i]=0;        }        sort(a+1,a+n+1,cmp);        for(int i=1;i<=n;i++)        {            int ind=a[i].index;            while(ind>=1&&!vis[ind])            {                vis[ind]=1;                sum[ind]=a[i].cnt;                ind--;            }        }        for(int i=1;i<=n;i++)            si1(b[i]);        sort(b+1,b+1+n);        LL ans=sum[b[1]];        LL mmax=ans-n-1;        for(int i=2;i<=n;i++)        {            LL smax=sum[b[i]];            if(smax>mmax)            {                ans=(ans+smax)%mod;                mmax=max(smax-i-n,mmax);            }            else            {                ans=(ans+mmax)%mod;            }        }    printf("%lld\n",ans);    }    return 0;}

Regular polygon

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 647    Accepted Submission(s): 236


Problem Description
On a two-dimensional plane, give you n integer points. Your task is to figure out how many different regular polygon these points can make.
 

Input
The input file consists of several test cases. Each case the first line is a numbers N (N <= 500). The next N lines ,each line contain two number Xi and Yi(-100 <= xi,yi <= 100), means the points’ position.(the data assures no two points share the same position.)
 

Output
For each case, output a number means how many different regular polygon these points can make.
 

Sample Input
40 00 11 01 160 00 11 01 12 02 1
 

Sample Output
12
 

Source
2017 Multi-University Training Contest - Team 2
 

Recommend
liuyiding   |   We have carefully selected several similar problems for you:  6055 6054 6053 6052 6051 


               题解:给你N个点的坐标,让你判断有多少个不同的正多边形(其实就是正方形)因为输入的是整数。需要用到坐标旋转还有极坐标。之前有做过类似的题目,还用了二分查找。



ac code:

#include <stdio.h>#include <iostream>  #include <algorithm>  #include <cmath>  #include <vector>  #include <string>  #include <cstring>  #pragma warning(disable:4996)  using namespace std;    struct no {      int x;      int y;  }node[1005];    int num;    bool cmp(const no& node1, const no& node2)  {      if (node1.x == node2.x)      {          return node1.y < node2.y;      }      else      {          return node1.x < node2.x;      }  }    bool binsearch(int x, int y)  {      int left = -1, right = num, mid;        while (right - left > 1)      {          mid = (left + right) / 2;          if (node[mid].x == x && node[mid].y == y)              return true;          else          {              if ((node[mid].x == x && node[mid].y < y) || (x > node[mid].x))              {                  left = mid;              }              else              {                  right = mid;              }          }      }      return false;  }    int main()  {      int i, j, pos_x1, pos_y1, pos_x2, pos_y2, ans;      while (cin >> num)      {          if (num == 0)              break;          ans = 0;          for (i = 0; i < num; i++)          {              scanf("%d%d", &node[i].x, &node[i].y);          }          sort(node, node + num, cmp);            for (i = 0; i < num; i++)          {              for (j = i + 1; j < num; j++)              {                  pos_x1 = node[i].x + (node[i].y - node[j].y);                  pos_y1 = node[i].y - (node[i].x - node[j].x);                    pos_x2 = node[j].x + (node[i].y - node[j].y);                  pos_y2 = node[j].y - (node[i].x - node[j].x);                    if ((binsearch(pos_x1, pos_y1)) && (binsearch(pos_x2, pos_y2)))                      ans++;                    pos_x1 = node[i].x - (node[i].y - node[j].y);                  pos_y1 = node[i].y + (node[i].x - node[j].x);                      pos_x2 = node[j].x - (node[i].y - node[j].y);                  pos_y2 = node[j].y + (node[i].x - node[j].x);                    if ((binsearch(pos_x1, pos_y1)) && (binsearch(pos_x2, pos_y2)))                      ans++;              }          }          cout << ans / 4 << endl;      }      return 0;  }  



剩下的日后继续补上…

原创粉丝点击