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
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 integersN ,X ,Y ,the meaning is mentioned above.
The second line consists ofN characters,each character is “A ” “B ” or “C ”,which represents the answer of Derek for each question.
The third line consists ofN characters,the same form as the second line,which represents the answer of Alfia for each question.
Data Range:1≤N≤80000 ,0≤X,Y≤N, ∑Ti=1N≤300000
For each test case,there will be three lines.
The first line consists of three integers
The second line consists of
The third line consists of
Data Range:
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 ”.
Please print “
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+1…a2n . Just like always, there are some restrictions on an+1…a2n : 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.
Given two integer sequences {ai} and {bi} with the same length n, you are to find the next n numbers of {ai}:
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.
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
27HintFor 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; }
阅读全文
0 0
- 2017 多校系列 2
- 2017 多校系列 1
- 2017 多校系列 3
- 2017 多校系列 4
- 2017 多校系列 5
- 2017 多校系列 6
- oracle系列笔记(2)---多表查询
- ○ 多客系列
- 笑话系列2
- StringGrid系列文章2
- StrutsCatalog系列(2)--LinkOnlyToActions
- 3G系列2
- linux系列2
- GeoRSS 学习系列(2)
- Learning python 系列2
- ajax系列教程(2)
- Microwindow系列(2)--结构
- [SilkyBible] XviD系列-2
- 使用POST、GET、AsyncHttpClient创造服务端用手机端来连接进行登录
- java虚拟机内存模式,栈和堆
- linux 设备驱动之字符设备
- HDU 4694 [支配树]
- eclipse中的tomcat启动报错“The JRE could not be found. Edit the server and change the JRE location.”
- 2017 多校系列 2
- 欧拉函数应用
- 40个Java多线程问题总结
- 1095. Cars on Campus (30) <结构体排序>
- C
- note_cloud--加载笔记列表
- Android图片优化,减少内存压力,提高app流畅度
- Ehcache教程(一)----Ehcache简介
- bzoj1395: [Baltic2005]Trip