2000年台湾大专题。。。英语阅读输入输出专场。。我只能说很强势。。

M. Frequent Subsets Problem

The frequent subset problem is defined as follows. Suppose UU={1, 2,\ldots…,N} is the universe, and S_{1}S​1​​, S_{2}S​2​​,\ldots…,S_{M}S​M​​ are MM sets over UU. Given a positive constant \alphaα, 0<\alpha \leq 10<α≤1, a subset BB (B \neq 0B≠0) is α-frequent if it is contained in at least \alpha MαM sets of S_{1}S​1​​, S_{2}S​2​​,\ldots…,S_{M}S​M​​, i.e. \left | \left \{ i:B\subseteq S_{i} \right \} \right | \geq \alpha M∣{i:B⊆S​i​​}∣≥αM. The frequent subset problem is to find all the subsets that are α-frequent. For example, let U=\{1, 2,3,4,5\}U={1,2,3,4,5}, M=3M=3, \alpha =0.5α=0.5, and S_{1}=\{1, 5\}S​1​​={1,5}, S_{2}=\{1,2,5\}S​2​​={1,2,5}, S_{3}=\{1,3,4\}S​3​​={1,3,4}. Then there are 33 α-frequent subsets of UU, which are \{1\}{1},\{5\}{5} and \{1,5\}{1,5}.

Input Format

The first line contains two numbers NN and \alphaα, where NN is a positive integers, and \alphaα is a floating-point number between 0 and 1. Each of the subsequent lines contains a set which consists of a sequence of positive integers separated by blanks, i.e., line i + 1i+1 contains S_{i}S​i​​, 1 \le i \le M1≤i≤M . Your program should be able to handle NN up to 2020 and MM up to 5050.

Output Format

The number of \alphaα-frequent subsets.

样例输入

15 0.4
1 8 14 4 13 2
3 7 11 6
10 8 4 2
9 3 12 7 15 2
8 3 2 4 5

样例输出

11

输入坑。。还有题面英语阅读就顺便说下。。
然后把M个集合变成二进制,相应位代表该数字是否存在。暴力枚举0~(1<<n)-1,每个数字代表一个集合,然后检查1~m里面有几个枚举集合是他的子集。把两个数字或一下如果是子集的话数字不变,不是则改变。
 #include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define clr_1(x) memset(x,-1,sizeof(x))
#define LL long long
#define mod 1000000007
using namespace std;
const int N=1e2+;
int vis[N][N];
int num[N];
int n,m,T,k,ct,len,p,gg,tt;
double aef;
string s;
int main()
{
scanf("%d%lf",&n,&aef);
m=;
clr(vis);
clr(num);
getline(cin,s);
while(getline(cin,s))
{
m++;
k=;
for(int i=;i<s.size();i++)
if(s[i]>'' || s[i]<'')
{
vis[m][k]++;
k=;
}
else
{
k*=;
k+=s[i]-'';
}
vis[m][k]++;
for(int i=;i<=n;i++)
{
if(vis[m][i])
num[m]|=(<<(i-));
}
}
tt=m;
if(abs(m*aef-(int)(m*aef))<=1e-)
tt=(int)(m*aef+0.5);
else
tt=m*aef+;
p=;
len=(<<n);
for(int i=;i<len;i++)
{
ct=;
for(int j=;j<=m;j++)
if((i|num[j])==num[j])
ct++;
if(ct>=tt)
p++;
}
printf("%d\n",p);
return ;
}

L, The Heaviest Non-decreasing Subsequence Problem

Let SS be a sequence of integers s_{1}s​1​​, s_{2}s​2​​, ......, s_{n}s​n​​Each integer is is associated with a weight by the following rules:

(1) If is is negative, then its weight is 00.

(2) If is is greater than or equal to 1000010000, then its weight is 55. Furthermore, the real integer value of s_{i}s​i​​ is s_{i}-10000s​i​​−10000 . For example, if s_{i}s​i​​is 1010110101, then is is reset to 101101 and its weight is 55.

(3) Otherwise, its weight is 11.

A non-decreasing subsequence of SS is a subsequence s_{i1}s​i1​​, s_{i2}s​i2​​, ......, s_{ik}s​ik​​, with i_{1}<i_{2}\ ...\ <i_{k}i​1​​<i​2​​ ... <i​k​​, such that, for all 1 \leq j<k1≤j<k, we have s_{ij}<s_{ij+1}s​ij​​<s​ij+1​​.

A heaviest non-decreasing subsequence of SSis a non-decreasing subsequence with the maximum sum of weights.

Write a program that reads a sequence of integers, and outputs the weight of its

heaviest non-decreasing subsequence. For example, given the following sequence:

8080 7575 7373 9393 7373 7373 1010110101 9797 -1−1 -1−1 114114 -1−11011310113 118118

The heaviest non-decreasing subsequence of the sequence is <73, 73, 73, 101, 113, 118><73,73,73,101,113,118> with the total weight being 1+1+1+5+5+1 = 141+1+1+5+5+1=14. Therefore, your program should output 1414 in this example.

We guarantee that the length of the sequence does not exceed 2*10^{5}2∗10​5​​

Input Format

A list of integers separated by blanks:s_{1}s​1​​, s_{2}s​2​​,......,s_{n}s​n​​

Output Format

A positive integer that is the weight of the heaviest non-decreasing subsequence.

样例输入

80 75 73 93 73 73 10101 97 -1 -1 114 -1 10113 118

样例输出

14

最长不下降子序列问题。用树状数组的标准nlogn做法。
 #include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define clr_1(x) memset(x,-1,sizeof(x))
#define LL long long
#define mod 1000000007
using namespace std;
const int N=1e4+;
const int NN=1e4+;
const int M=2e5+;
int bit[N];
int val[M],wei[M],ans,maxn;
int sum(int i)
{
int s=;
while(i>)
{
s=max(s,bit[i]);
i-=i&-i;
}
return s;
}
void add(int i,int x)
{
while(i<=NN)
{
bit[i]=max(bit[i],x);
i+=i&-i;
}
return ;
}
int ct,n,m,k,T;
int main()
{
n=;
while(scanf("%d",&val[n])!=EOF)
{
if(val[n]>=)
n++;
}
n--;
for(int i=;i<=n;i++)
{
if(val[i]>=)
{
val[i]-=;
wei[i]=;
}
else
wei[i]=;
}
clr(bit);
maxn=;
for(int i=;i<=n;i++)
{
ans=sum(val[i])+wei[i];
maxn=max(maxn,ans);
add(val[i],ans);
}
printf("%d\n",maxn);
return ;
}

J.Minimum Distance in a Star Graph

In this problem, we will define a graph called star graph, and the question is to find the minimum distance between two given nodes in the star graph.

Given an integer nn, an n-dimensionaln−dimensionalstar graph, also referred to as S_{n}S​n​​, is an undirected graph consisting of n!n! nodes (or vertices) and ((n-1)\ *\ n!)/2((n−1) ∗ n!)/2 edges. Each node is uniquely assigned a label x_{1}\ x_{2}\ ...\ x_{n}x​1​​ x​2​​ ... x​n​​which is any permutation of the n digits {1, 2, 3, ..., n}1,2,3,...,n. For instance, an S_{4}S​4​​ has the following 24 nodes {1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, 2341, 2413, 2431, 3124, 3142, 3214, 3241, 3412, 3421, 4123, 4132, 4213, 4231, 4312, 4321}1234,1243,1324,1342,1423,1432,2134,2143,2314,2341,2413,2431,3124,3142,3214,3241,3412,3421,4123,4132,4213,4231,4312,4321. For each node with label x_{1}\ x_{2} x_{3}\ x_{4}\ ...\ x_{n}x​1​​ x​2​​x​3​​ x​4​​ ... x​n​​, it has n-1n−1 edges connecting to nodes x_{2}\ x_{1}\ x_{3}\ x_{4}\ ...\ x_{n}x​2​​ x​1​​ x​3​​ x​4​​ ... x​n​​, x_{3}\ x_{2}\ x_{1}\ x_{4}\ ...\ x_{n}x​3​​ x​2​​ x​1​​ x​4​​ ... x​n​​, x_{4}\ x_{2}\ x_{3}\ x_{1}\ ...\ x_{n}x​4​​ x​2​​ xx_{n}\ x_{2}\ x_{3}\ x_{4}\ ...\ x_{1}n-1d-thx_{1}\ x_{2}\ x_{3}\ x_{4}\ ...\ x_{n}d = 2, ..., nS_{4}12343213432144231S_{4}abcd​3​​ x​1​​ ... x​n​​, ..., and x​n​​ x​2​​ x​3​​ x​4​​ ... x​1​​. That is, the n−1adjacent nodes are obtained by swapping the first symbol and the d−th symbol of x​1​​ x​2​​ x​3​​ x​4​​ ... x​n​​, for d=2,...,n. For instance, in S​4​​, node 1234 has 3 edges connecting to nodes 2134, 3214, and 4231. The following figure shows how S​4​​ looks (note that the symbols a, b, c, and d are not nodes; we only use them to show the connectivity between nodes; this is for the clarity of the figure).

In this problem, you are given the following inputs:

  • nn: the dimension of the star graph. We assume that nn ranges from 44 to 99.
  • Two nodes x_{1}x​1​​ x_{2}x​2​​ x_{3}x​3​​ ... x_{n}x​n​​ and y_{1}y​1​​ y_{2}y​2​​ y_{3}\ ...\ y_{n}y​3​​ ... y​n​​ in S_{n}S​n​​.

You have to calculate the distance between these two nodes (which is an integer).

Input Format

nn (dimension of the star graph)

A list of 55 pairs of nodes.

Output Format

A list of 55 values, each representing the distance of a pair of nodes.

样例输入

4
1234 4231
1234 3124
2341 1324
3214 4213
3214 2143

样例输出

1
2
2
1
3

题意就是把第一串变成第二串要几步,变换规则是只能把第一个位置和任意一个位置交换。
跟普通的通过交换位置把一个混乱序列变为一个指定序列相似,每个位置的数直接交换到他该到的位置就行。
但有k个交换循环就要加(k-1)*2的次数,因为除了第一个数字在的循环,其他循环节都得某个位置交换到1以后再交换,比正常直接交换多2。
 #include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define clr_1(x) memset(x,-1,sizeof(x))
#define LL long long
#define mod 1000000007
using namespace std;
const int N=1e2+;
const int NN=1e4+;
const int M=2e5+;
int n;
string s1,s2;
int num[N],ct,flag=;;
int main()
{
scanf("%d",&n);
for(int kase=;kase<=;kase++)
{
cin>>s1;
cin>>s2;
for(int i=;i<s2.size();i++)
num[s2[i]-'']=i;
ct=;
flag=;
for(int i=;i<s1.size();i++)
{
if(s1[i]!=s2[i] && i>)
flag++;
while(s1[i]!=s2[i])
{
swap(s1[i],s1[num[s1[i]-'']]);
ct++;
}
}
if(flag)
ct+=*flag;
printf("%d\n",ct);
}
return ;
}

H. A Cache Simulator

Cache memories have been used widely in current microprocessor systems. In this problem, you are asked to write a program for a cache simulator. The cache has the following metrics:

1. The cache size is 1 KB (K-byte).

2. The cache uses the direct mapped approach.

3. The cache line size is 16 bytes.

4. The cacheable memory size is 256MB.

Your program will report a hit or miss when an address is given to the cache simulator. This is often called trace simulation. Initially, all of the cache lines are in the invalid state. When a memory line is first brought into the cache, the allocated cache entry transits into the valid state. Assume that a miss causes the filling of a whole cache line.

Input Format

Up to 100100 lines of address can be given in the file. Each line consists of an address given to the simulator. The address is given in hexadecimal form. We assume that each address references only one byte of data. The input file ends at the line with the word ENDEND.

Output Format

Report either HitHit or MissMiss for each of the given addresses. The last line reports cache hit ratio in percentage, that is, the number of hits divided by the number of total addresses given.

样例输入

AAAA000
00010B2
00010BA
END

样例输出

Miss
Miss
Hit
Hit ratio = 33.33%

已经忘了计算机组成原理,队友写的,队友解释一番我才懂cache内存怎么分配。。
学过计组,英语好的话你就懂了。。。
 //zq's code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = ;
const int cacheSize = ;
const int lineSize = ; int cnt[N];
string s;
int a, b; void slove() {
memset(cnt, -, sizeof(cnt));
a = ;
b = ;
while(cin >> s){
if(s == "END") break;
b ++;
int ans = ;
for(int i = ; i < s.size(); ++ i) {
int tmp;
if(s[i] >= 'A') {
tmp = s[i] - 'A' + ;
}
else {
tmp = s[i] - '';
}
ans = ans * + tmp;
}
ans = ans / cacheSize; if(cnt[ans%lineSize] == ans) {
puts("Hit");
++ a;
}
else {
puts("Miss");
}
cnt[ans%lineSize] = ans;
}
printf("Hit ratio = %.2lf", 100.0 * a / b);
puts("%");
} int main() {
slove();
return ;
}

G.Finding the Radius for an Inserted Circle

Three circles C_{a}C​a​​, C_{b}C​b​​, and C_{c}C​c​​, all with radius RRand tangent to each other, are located in two-dimensional space as shown in Figure 11. A smaller circle C_{1}C​1​​ with radius R_{1}R​1​​ (R_{1}<RR​1​​<R) is then inserted into the blank area bounded by C_{a}C​a​​, C_{b}C​b​​, and C_{c}C​c​​ so that C_{1}C​1​​ is tangent to the three outer circles, C_{a}C​a​​, C_{b}C​b​​, and C_{c}C​c​​. Now, we keep inserting a number of smaller and smaller circles C_{k}\ (2 \leq k \leq N)C​k​​ (2≤k≤N) with the corresponding radius R_{k}R​k​​ into the blank area bounded by C_{a}C​a​​, C_{c}C​c​​ and C_{k-1}C​k−1​​ (2 \leq k \leq N)(2≤k≤N), so that every time when the insertion occurs, the inserted circle C_{k}C​k​​ is always tangent to the three outer circles C_{a}C​a​​, C_{c}C​c​​ and C_{k-1}C​k−1​​, as shown in Figure 11

Figure 1.

(Left) Inserting a smaller circle C_{1}C​1​​ into a blank area bounded by the circle C_{a}C​a​​, C_{b}C​b​​ and C_{c}C​c​​.

(Right) An enlarged view of inserting a smaller and smaller circle C_{k}C​k​​ into a blank area bounded by C_{a}C​a​​, C_{c}C​c​​ and C_{k-1}C​k−1​​ (2 \leq k \leq N2≤k≤N), so that the inserted circle C_{k}C​k​​ is always tangent to the three outer circles, C_{a}C​a​​, C_{c}C​c​​, and C_{k-1}C​k−1​​.

Now, given the parameters RR and kk, please write a program to calculate the value of R_{k}R​k​​, i.e., the radius of the k-thk−th inserted circle. Please note that since the value of R_kR​k​​ may not be an integer, you only need to report theinteger part of R_{k}R​k​​. For example, if you find that R_{k}R​k​​ = 1259.89981259.8998 for some kk, then the answer you should report is 12591259.

Another example, if R_{k}R​k​​ = 39.102939.1029 for some kk, then the answer you should report is 3939.

Assume that the total number of the inserted circles is no more than 1010, i.e., N \leq 10N≤10. Furthermore, you may assume \pi = 3.14159π=3.14159. The range of each parameter is as below:

1 \leq k \leq N1≤k≤N, and 10^{4} \leq R \leq 10^{7}10​4​​≤R≤10​7​​.

Input Format

Contains l + 3l+3 lines.

Line 11: ll ----------------- the number of test cases, ll is an integer.

Line 22: RR ---------------- RR is a an integer followed by a decimal point,then followed by a digit.

Line 33: kk ---------------- test case #11, kk is an integer.

\ldots…

Line i+2i+2: kk ----------------- test case # ii.

\ldots…

Line l +2l+2: kk ------------ test case #ll.

Line l + 3l+3: -1−1 ---------- a constant -1−1representing the end of the input file.

Output Format

Contains ll lines.

Line 11: kk R_{k}R​k​​ ----------------output for the value ofkk and R_{k}R​k​​ at the test case #11, each of which should be separated by a blank.

\ldots…

Line ii: kk R_{k}R​k​​ ----------------output for kk and the value of R_{k}R​k​​ at the test case # ii, each of which should be separated by a blank.

Line ll: kk R_{k}R​k​​ ----------------output for kk and the value ofR_{k}R​k​​ at the test case # ll, each of which should be separated by a blank.

样例输入

1
152973.6
1
-1

样例输出

1 23665

题意就是求三个相切的圆(Ca,Cb,Cc的半径为R)内的缝隙内的与三个圆相切的圆C1的半径作为r1,然后选择Ca,Cb和r1以同样方法做出C2和半径r2,依此做出r3..r4...rn。
又是很长很难理解的题面和奇怪输入坑,倒是取整没坑。这题就是高中数学题。r1是求一个求等边三角形的重心(三角形的三个顶点是三个圆圆心),列个方程然后就能求出r1了。接下来这个圆心和ca,cb的圆心又能求出r2。然后r3,r4。。。解个三角形方程求出递推式就能求出所有的ri。
 #include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define clr_1(x) memset(x,-1,sizeof(x))
#define LL long long
#define mod 1000000007
using namespace std;
const int N=1e2+;
double rk[N];
double r,t,lefted,R;
int n,T,k,q;
int main()
{
while(scanf("%d",&n)!=EOF && n!=-)
{
scanf("%lf",&R);
rk[]=R;
lefted=sqrt()*R;
for(int i=;i>=;i--)
{
t=lefted-rk[i+];
rk[i]=t*t//(t+R);
lefted=lefted-rk[i+]-rk[i];
}
for(int i=;i<=;i++)
swap(rk[i],rk[-i+]);
for(int i=;i<=n;i++)
{
scanf("%d",&q);
printf("%d %d\n",q,int(rk[q]+(1e-)));
}
}
return ;
}

F.Overlapping Rectangles

There are nn rectangles on the plane. The problem is to find the area of the union of these rectangles. Note that these rectangles might overlap with each other, and the overlapped areas of these rectangles shall not be counted more than once. For example, given a rectangle AA with the bottom left corner located at (0, 0)(0,0) and the top right corner at (2, 2)(2,2), and the other rectangle BB with the bottom left corner located at (1,1)(1,1) and the top right corner at (3,3)(3,3), it follows that the area of the union of AA and BB should be 77, instead of 88.

Although the problem looks simple at the first glance, it might take a while to figure out how to do it correctly. Note that the shape of the union can be very complicated, and the intersected areas can be overlapped by more than two rectangles.

Note:

(1) The coordinates of these rectangles are given in integers. So you do not have to worry about the floating point round-off errors. However, these integers can be as large as 1,000,0001,000,000.

(2) To make the problem easier, you do not have to worry about the sum of the areas exceeding the long integer precision. That is, you can assume that the total area does not result in integer overflow.

Input Format

Several sets of rectangles configurations. The inputs are a list of integers. Within each set, the first integer (in a single line) represents the number of rectangles, n, which can be as large as 10001000. After n, there will be n lines representing the n rectangles; each line contains four integers <a, b, c, d><a,b,c,d> , which means that the bottom left corner of the rectangle is located at (a, b)(a,b), and the top right corner of the rectangle is located at (c, d)(c,d). Note that integers aa, bb, cc, dd can be as large as 1,000,0001,000,000.

These configurations of rectangles occur repetitively in the input as the pattern described above. An integer n = 0n=0 (zero) signifies the end of input.

Output Format

For each set of the rectangles configurations appeared in the input, calculate the total area of the union of the rectangles. Again, these rectangles might overlap each other, and the intersecting areas of these rectangles can only be counted once. Output a single star '*' to signify the end of outputs.

样例输入

2
0 0 2 2
1 1 3 3
3
0 0 1 1
2 2 3 3
4 4 5 5
0

样例输出

7
3
*

扫描线求面积并题。放个队友代码~
 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring> using namespace std; typedef long long ll;
const int inf = 0x3f3f3f3f;
const int MAXN = ;
int n;
int t[MAXN];
int HASH[MAXN],sum[MAXN];
struct data{
int x1,x2,y;int f;
}a[MAXN];
inline bool operator<(data a,data b){
return a.y<b.y;
}
int findup(int x)
{
int l=,r=*n;
while(l<=r)
{
int mid=(l+r)>>;
if(HASH[mid]<x)l=mid+;
else if(HASH[mid]==x)return mid;
else r=mid-;
}
}
void PUSHUP(int k,int l,int r)
{
if(t[k])
sum[k]=HASH[r+]-HASH[l];
else if(l==r)
sum[k]=;
else
sum[k]=sum[k<<]+sum[k<<|];
}
void update(int k,int l,int r,int x,int y,int f)
{
if(x==l&&y==r)
{
t[k]+=f;PUSHUP(k,l,r);
return;
}
int mid=(l+r)>>;
if(y<=mid)
update(k<<,l,mid,x,y,f);
else if(x>mid)
update(k<<|,mid+,r,x,y,f);
else
{
update(k<<,l,mid,x,mid,f);
update(k<<|,mid+,r,mid+,y,f);
}
PUSHUP(k,l,r);
}
void solve(){
memset(t,,sizeof(t));
memset(sum,,sizeof(sum));
int x1,y1,x2,y2;
for(int i=;i<=n;i++){
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
a[*i-].x1=a[*i].x1=x1;
a[*i-].x2=a[*i].x2=x2;
a[*i-].y=y1;a[*i].y=y2;
a[*i-].f=;a[*i].f=-;
HASH[*i-]=x1;HASH[*i]=x2;
}
sort(HASH+,HASH+*n+);
sort(a+,a+*n+);
int ans=;
for(int i=;i<=*n;i++){
int l=findup(a[i].x1),r=findup(a[i].x2)-;
if(l<=r)update(,,*n,l,r,a[i].f);
ans+=sum[]*(a[i+].y-a[i].y);
}
printf("%d\n",ans);
}
int main()
{
while(scanf("%d",&n))
{
if(n==){
printf("*\n");
break;
}
solve();
}
return ;
}

C.Auction Bidding

Company ABC is holding an antique auction. In the auction, there are NN, 1 \leq N \leq 10001≤N≤1000, lots. We number the lots from 11 to NN. There are MM, 1 \leq M \leq 5001≤M≤500, bidders participated in the auction. We number the bidders from11 to MM. The winning bid for each lot is determined by the following rules:

• Each lot has a reserved price, which is a positive integer.

• Each bidder may submit at most one bid to each lot whose amount must be a positive integer.

• A valid bid for a lot is one that is at least the reserved price for the lot. All invalid bids are not considered.

• The largest valid bid wins the lot and is called the winning bid. In case of tie bids, the bidder with the smaller bidder number wins. If there is no valid bid for a lot, then this lot is not sold.

• The second largest bid is a valid bid that does not win if one exists; otherwise, it is the reserved price.

• If a bidder wins a lot, then the final hammer price for this lot is either 10\%10% over the second largest bid or the largest valid bid, depending on which one is smaller. If the final hammer price is not an integer, then it is truncated to the nearest integer.

• Given the reserved price and the bids for each lot, your task is to decide the total final hammer prices for a given k, 0 < k \leq M0<k≤M, bidders.

Input Format

The input contains N + 3 + kN+3+k lines.

Line 11: NN

Line 22: MM

Line 33: r_{1}, b_{1,1}, p_{1,1}, b_{1,2}, p{1,2}, -1r​1​​,b​1,1​​,p​1,1​​,b​1,2​​,p1,2,−1

\ldots…

Line i + 2i+2: r_{i}, b_{i,1}, p_{i,1}, b_{i,2}, p{i,2}, -1r​i​​,b​i,1​​,p​i,1​​,b​i,2​​,pi,2,−1

\ldots…

Line N + 2N+2: r_{N}, b_{N,1}, p_{N,1}, b_{N,2}, p_{N,2}, -1r​N​​,b​N,1​​,p​N,1​​,b​N,2​​,p​N,2​​,−1

Line N + 3N+3: kk

Line N + 4N+4: q_{1}q​1​​

\ldots…

Line N + 3 + iN+3+i: q_{i}q​i​​

\ldots…

Line N + 3 + kN+3+k: q_{k}q​k​​

In Line i + 2i+2, r_{i}r​i​​ is the reserved price for lot ii. The number b_{i,j}b​i,j​​ and p{i,j}pi,j are the j^{th}j​th​​ bid for lot ii from bidder b_{i,j}b​i,j​​with the amount p_{i,j}p​i,j​​ . Note that a space is between each number. The number -1−1 is added to mark the end of bids for a lot. In Line N+3N+3, kk is given. In line N + 3 + iN+3+i, you are asked to provide the total hammer prices for bidder q_{i}q​i​​.

Output Format:

The output contains kk lines.

Line 11: h_{1}h​1​​

\ldots…

Line ii: h_{i}h​i​​

\ldots…

Line kk: h_{k}h​k​​

The total hammer prices for bidder q_{i}q​i​​ is h_{i}h​i​​.

Hint

In the sample, the bidder 11 got the the first lot 11 at hammer price 1313.

样例输入

3
3
11 2 12 1 15 -1
5 3 4 -1
23 1 32 2 35 3 40 -1
1
1

样例输出

13

读入奇怪咯,做到后面习惯了。
另题意不清,逛问答区已成交题习惯。他取的成交价是第二有效价格+10%和第一有效价格的最大者,这点注意到就行了。
其他就是读入sort下的事情了。
 #include <bits/stdc++.h>
using namespace std;
const int N = ; int p[N];
struct Node{
int pi;
int id;
bool operator < (const Node &a) const {
if(pi == a.pi) return id < a.id;
return pi > a.pi;
}
}; int main() {
int n, m;
while(cin >> n >> m) {
memset(p, , sizeof(p));
for(int i = ; i < n; ++ i) {
int x;
int y;
int limit;
cin >> limit;
vector<Node> v;
v.push_back(Node{limit, });
while(cin >> x) {
if(x == -) {
break;
}
cin >> y;
if(y >= limit) {
v.push_back(Node{y, x});
}
}
sort(v.begin(), v.end());
if(v.size() > ) {
p[v[].id] += min(int(v[].pi * 1.1), int(v[].pi));
}
}
int k;
cin >> k;
while(k --) {
int x;
cin >> x;
cout << p[x] << "\n";
}
}
return ;
}

B. Train Seats Reservation

You are given a list of train stations, say from the station 11 to the station 100100.

The passengers can order several tickets from one station to another before the train leaves the station one. We will issue one train from the station 11 to the station 100100 after all reservations have been made. Write a program to determine the minimum number of seats required for all passengers so that all reservations are satisfied without any conflict.

Note that one single seat can be used by several passengers as long as there are no conflicts between them. For example, a passenger from station 11 to station 1010 can share a seat with another passenger from station 3030 to 6060.

Input Format

Several sets of ticket reservations. The inputs are a list of integers. Within each set, the first integer (in a single line) represents the number of orders, nn, which can be as large as 10001000. After nn, there will be nn lines representing the nnreservations; each line contains three integers s, t, ks,t,k, which means that the reservation needskk seats from the station ss to the station tt.These ticket reservations occur repetitively in the input as the pattern described above. An integer n = 0n=0 (zero) signifies the end of input.

Output Format

For each set of ticket reservations appeared in the input, calculate the minimum number of seats required so that all reservations are satisfied without conflicts. Output a single star '*' to signify the end of outputs.

样例输入

2
1 10 8
20 50 20
3
2 30 5
20 80 20
40 90 40
0

样例输出

20
60
*

日常阅读理解,队友过得。贴份队友代码。
 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = ;
ll v[N];
int n; void slove(int n) {
ll res = ;
memset(v, , sizeof(v));
for(int i = ; i < n; ++ i) {
int s, t;
ll x;
cin >> s >> t >> x;
for(int j = s; j < t; ++ j) {
v[j] += x;
}
}
for(int i = ; i < N; ++ i) {
res = max(res, v[i]);
}
cout << res << endl;
} int main() {
while(cin >> n) {
if(n == ) {
puts("*");
}
else{
slove(n);
}
}
return ;
}

A. Weather Patterns

Consider a system which is described at any time as being in one of a set of NN distinct states, 1,2,3,...,N1,2,3,...,N. We denote the time instants associated with state changes as t = 1,2,...t=1,2,..., and the actual state at time tt as a_{ij}=p=[s_{i}=j\ |\ s_{i-1}=i], 1\le i,j \le Na​ij​​=p=[s​i​​=j ∣ s​i−1​​=i],1≤i,j≤N. For the special case of a discrete, first order, Markovchain, the probabilistic description for the current state (at time tt) and the predecessor state is s_{t}s​t​​. Furthermore we only consider those processes being independent of time, thereby leading to the set of state transition probability a_{ij}a​ij​​ of the form: with the properties a_{ij} \geq 0a​ij​​≥0 and \sum_{i=1}^{N} A_{ij} = 1∑​i=1​N​​A​ij​​=1. The stochastic process can be called an observable Markovmodel. Now, let us consider the problem of a simple 4-state Markov model of weather. We assume that once a day (e.g., at noon), the weather is observed as being one of the following:

State 11: snow

State 22: rain

State 33: cloudy

State 44: sunny

The matrix A of state transition probabilities is:

A = \{a_{ij}\}= \begin{Bmatrix} a_{11}&a_{12}&a_{13}&a_{14} \\ a_{21}&a_{22}&a_{23}&a_{24} \\ a_{31}&a_{32}&a_{33}&a_{34} \\ a_{41}&a_{42}&a_{43}&a_{44} \end{Bmatrix}A={a​ij​​}=​⎩​⎪​⎪​⎨​⎪​⎪​⎧​​​a​11​​​a​21​​​a​31​​​a​41​​​​​a​12​​​a​22​​​a​32​​​a​42​​​​​a​13​​​a​23​​​a​33​​​a​43​​​​​a​14​​​a​24​​​a​34​​​a​44​​​​​⎭​⎪​⎪​⎬​⎪​⎪​⎫​​

Given the model, several interestingquestions about weather patterns over time can be asked (and answered). We canask the question: what is the probability (according to the given model) thatthe weather for the next k days willbe? Another interesting question we can ask: given that the model is in a knownstate, what is the expected number of consecutive days to stay in that state?Let us define the observation sequence OOas O = \left \{ s_{1}, s_{2}, s_{3}, ... , s_{k} \right \}O={s​1​​,s​2​​,s​3​​,...,s​k​​}, and the probability of the observation sequence OOgiven the model is defined as p(O|model)p(O∣model). Also, let the expected number of consecutive days to stayin state ii be E_{i}E​i​​. Assume that the initial state probabilities p[s_{1} = i] = 1, 1 \leq i \leq Np[s​1​​=i]=1,1≤i≤N. Bothp(O|model)p(O∣model) and E_{i}E​i​​ are real numbers.

Input Format

Line 11~44 for the state transition probabilities. Line 55 for the observation sequence O_{1}O​1​​, and line 66 for the observation sequence O_{2}O​2​​. Line 77and line 88 for the states of interest to find the expected number of consecutive days to stay in these states.

Line 11: a_{11}\ a_{12}\ a_{13}\ a_{14}a​11​​ a​12​​ a​13​​ a​14​​

Line 22: a_{21}\ a_{22}\ a_{23}\ a_{34}a​21​​ a​22​​ a​23​​ a​34​​

Line 33: a_{31}\ a_{32}\ a_{33}\ a_{34}a​31​​ a​32​​ a​33​​ a​34​​

Line 44: a_{41}\ a_{42}\ a_{43}\ a_{44}a​41​​ a​42​​ a​43​​ a​44​​

Line 55: s_{1}\ s_{2}\ s_{3}\ ...\ s_{k}s​1​​ s​2​​ s​3​​ ... s​k​​

Line 66: s_{1}\ s_{2}\ s_{3}\ ...\ s_{l}s​1​​ s​2​​ s​3​​ ... s​l​​

Line 77: ii

Line 88: jj

Output Format

Line 11 and line 22 are used to show the probabilities of the observation sequences O_{1}O​1​​and O_{2}O​2​​ respectively. Line 33 and line 44 are for the expected number of consecutive days to stay in states ii and jj respectively.

Line 11: p[O_{1} | model]p[O​1​​∣model]

Line 22: p[O_{2} | model]p[O​2​​∣model]

Line 33: E_{i}E​i​​

Line 44: E_{j}E​j​​

Please be reminded that the floating number should accurate to 10^{-8}10​−8​​.

样例输入

0.4 0.3 0.2 0.1
0.3 0.3 0.3 0.1
0.1 0.1 0.6 0.2
0.1 0.2 0.2 0.5
4 4 3 2 2 1 1 3 3
2 1 1 1 3 3 4
3
4

样例输出

0.00004320
0.00115200
2.50000000
2.00000000

前面我说错了,这才是阅读理解23333。
队友过得再贴一份队友代码:
 #include <bits/stdc++.h>
using namespace std; double m[][], m1[][], ans[][];
int a[];
double sum;
int cnt;
int k; long long int read_int(){
char r;
bool start=false,neg=false;
long long int ret=;
while(true){
r=getchar();
if((r-''< || r-''>) && r!='-' && !start){
continue;
}
if((r-''< || r-''>) && r!='-' && start){
break;
}
if(start)ret*=;
start=true;
if(r=='-')neg=true;
else ret+=r-'';
}
if(!neg)
return ret;
else
return -ret;
} int main() {
for (int i = ; i <= ; i++) {
for (int j = ; j <= ; j++) {
scanf("%lf", &m[i][j]);
scanf("\n");
}
}
cnt = ;
sum = ;
memset(ans, , sizeof(ans));
string str;
getline(cin, str);
for (int i = ; i < str.size(); i++) {
if (str[i] >= '' && str[i] <= ''){
a[++cnt] = str[i] - '';
}
}
for (int i = ; i <= cnt; i++){
sum = sum * m[a[i - ]][a[i]];
}
printf("%.8lf\n", sum);
scanf("\n");
cnt = ;
sum = ;
memset(ans, , sizeof(ans));
getline(cin, str);
for (int i = ; i < str.size(); i++) {
if (str[i] >= '' && str[i] <= '') {
a[++cnt] = str[i] - '';
}
}
for (int i = ; i <= cnt; i++) {
sum = sum * m[a[i - ]][a[i]];
}
printf("%.8lf\n", sum);
scanf("%d", &k);
double temp = ;
sum = ;
for (int i = ; i <= ; i++) {
temp *= m[k][k];
sum += temp;
}
printf("%.8lf\n", sum);
scanf("%d", &k);
temp = ;
sum = ;
for (int i = ; i <= ; i++) {
temp *= m[k][k];
sum += temp;
}
printf("%.8lf\n", sum);
return ;
}

2017 icpc 南宁网络赛的更多相关文章

  1. 2017 icpc 沈阳网络赛

    cable cable cable Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  2. 2017 icpc 西安网络赛

    F. Trig Function 样例输入 2 0 2 1 2 2 样例输出 998244352 0 2 找啊找啊找数列和论文.cosnx可以用切比雪夫多项式弄成(cosx)的多项式,然后去找到了相关 ...

  3. 2018 ICPC 沈阳网络赛

    2018 ICPC 沈阳网络赛 Call of Accepted 题目描述:求一个算式的最大值与最小值. solution 按普通算式计算方法做,只不过要同时记住最大值和最小值而已. Convex H ...

  4. 2018 ICPC 徐州网络赛

    2018 ICPC 徐州网络赛 A. Hard to prepare 题目描述:\(n\)个数围成一个环,每个数是\(0\)~\(2^k-1\),相邻两个数的同或值不为零,问方案数. solution ...

  5. hdu6212[区间dp] 2017青岛ACM-ICPC网络赛

    原题: BZOJ1032 (原题数据有问题) /*hdu6212[区间dp] 2017青岛ACM-ICPC网络赛*/ #include <bits/stdc++.h> using name ...

  6. 2019 ICPC 南昌网络赛

    2019 ICPC 南昌网络赛 比赛时间:2019.9.8 比赛链接:The 2019 Asia Nanchang First Round Online Programming Contest 总结 ...

  7. 2018 ICPC 焦作网络赛 E.Jiu Yuan Wants to Eat

    题意:四个操作,区间加,区间每个数乘,区间的数变成 2^64-1-x,求区间和. 题解:2^64-1-x=(2^64-1)-x 因为模数为2^64,-x%2^64=-1*x%2^64 由负数取模的性质 ...

  8. 2017年icpc西安网络赛 Maximum Flow (找规律+数位dp)

    题目 https://nanti.jisuanke.com/t/17118 题意 有n个点0,1,2...n-1,对于一个点对(i,j)满足i<j,那么连一条边,边权为i xor j,求0到n- ...

  9. 2017南宁网络赛 Problem J Minimum Distance in a Star Graph ( 模拟 )

    题意 : 乱七八糟说了一大堆,实际上就是问你从一个序列到另个序列最少经过多少步的变化,每一次变化只能取序列的任意一个元素去和首元素互换 分析 : 由于只能和第一个元素去互换这种操作,所以没啥最优的特别 ...

随机推荐

  1. c语言目录操作总结

    =================================================== char *getcwd( char *buffer, int maxlen ); (获取当前目 ...

  2. vue装逼神器简述

    主要是分享下用vuejs开发项目过程中遇到的问题,vuejs开发的优势和需要注意的地方. 项目主要页面:主页,最新,分类,分类列表,详情页,结果页,斗图(列表,制作页) 效果图: 地址:https:/ ...

  3. js_面向对象设计和行为委托设计模式

    最近换了新工作,面试过程中有多多少少的问题没有给的出答案,为自己的技术短板而促急. javascript中万物皆对象(键:值构成的一种数据),暂且不讨论这个句话的对与错,可以想象对象在javascri ...

  4. ORA-02291:parent key not found

    Hibernate operation: Could not execute JDBC batch update; SQL [insert into dchnpricecarchancesource ...

  5. linux信号Linux下Signal信号太详细了,终于找到了

    linux信号Linux下Signal信号太详细了,终于找到了 http://www.cppblog.com/sleepwom/archive/2010/12/27/137564.html

  6. 3.FireDAC组件快照

    TFDManager 连接定义和Connect连接管理  TFDConnection 数据库连接组件,支持三种连接方式:1.持久定义(有一个唯一名称和一个配置文件,可以由FDManager管理) 例: ...

  7. 【数位dp入门】【HDU4734】F(x)

    记录减的状态,表示还要凑多少才能达到当前值. 然后进行枚举即可.注意状态数不能重复. #include<bits/stdc++.h> #define N 10010 using names ...

  8. webview loadRequest

    // 所构建的NSURLRequest具有一个依赖于缓存响应的特定策略,cachePolicy取得策略,timeoutInterval取得超时值 [self.yourSite loadRequest: ...

  9. [New learn]讲解Objective-c的block知识-实践

    1.简介 在之前的文章[New learn]讲解Objective-c的block知识中介绍了block的相关知识.本章中我们将以一个实际例子来简单介绍一下block如何代替代理. 2.原有通过代理实 ...

  10. strtok的用法(文件操作)

    strtok :在一个字符串查找下一个符号 char *strtok( char *strToken, const char *strDelimit ); 返回值:返回指向在strToken字符串找到 ...