计蒜客----训练联盟赛ICPC Yokohama 2018

我喜欢给自己压力,必须得定一个很高的目标,逼自己朝着这个目标前进,不管会不会实现,都是一个动力。                                      ----喻言

                                    Digits Are Not Just Characters

Mr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII code sequences, not as numbers. For example, the files file10, file20 and file3 are listed in this order.Write a program which decides the orders of file names interpreting digit sequences as numeric values.Each file name consists of uppercase letters (from ‘A’ to ‘Z’), lowercase letters (from ‘a’ to ‘z’), and digits (from ‘0’ to ‘9’).A file name is looked upon as a sequence of items, each being either a letter or a number. Each single uppercase or lowercase letter forms a letter item. Each consecutive sequence of digits forms a number item.Two item are ordered as follows.

  • Number items come before letter items.
  • Two letter items are ordered by their ASCII codes.
  • Two number items are ordered by their values when interpreted as decimal

numbers. Two file names are compared item by item, starting from the top, and the order of the first different corresponding items decides the order of the file names. If one of them, say A, has more items than the other, B, and all the items of B are the same as the corresponding items of A, B should come before.For example, three file names in Sample Input 1, file10, file20, and file3 all start with the same sequence of four letter items f, i, l, and e, followed by a number item, 10, 20, and 3, respectively. Comparing numeric values of these number items, they are ordered as file3 < file10 < file20.

Input

The input consists of a single test case of the following format.n s0 s1 . . . snThe integer n in the first line gives the number of file names (s1 through sn) to be compared with the file name given in the next line (s0). Here, n satisfies 1 ≤ n ≤ 1000. The following n + 1 lines are file names, s0 through sn, one in each line. They have at least one and no more than nine characters. Each of the characters is either an uppercase letter, a lowercase letter, or a digit.Sequences of digits in the file names never start with a digit zero (0).

Output

For each of the file names, s1 through sn, output one line with a character indicating whether it should come before s0 or not. The character should be “-” if it is to be listed before s0; otherwise, it should be “+”, including cases where two names are identical.

输出时每行末尾的多余空格,不影响答案正确性

样例输入1复制

2 
file10 
file20 
file3

样例输出1复制

+
-

样例输入2复制

11 
X52Y 
X 
X5 
X52 
X52Y 
X52Y6 
32 
ABC 
XYZ 
x51y 
X8Y 
X222

样例输出2复制

-
-
-
+
+
-
-
+
+
-
+
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include//INT_MAX
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
typedef long long ll;
using namespace std;
const int mod=998244353;  
const int NM=1e7+10;
char s[1000][20];
int n,a[20],b[20];
bool pd(char c)
{
	if(c>='0'&&c<='9') 
		return true;
	return false;
}
void jh(char s[],int cd,int a[])
{
	for(int i=0;ib[ls])
				{
					puts("-"); 
					fg=true;
					break;
				}
				else if(a[ls]s[i][ls])
				{
					puts("-"); 
					fg=true; 
					break;
				}
				else if(s[0][ls]

计蒜客----训练联盟赛ICPC Yokohama 2018_第1张图片

计蒜客----训练联盟赛ICPC Yokohama 2018_第2张图片

image.png

输出时每行末尾的多余空格,不影响答案正确性

样例输入1复制

6 
0 1 3 5 6 9

样例输出1复制

4

样例输入2复制

7 
1 4 7 3 2 6 5

样例输出2复制

7

样例输入3复制

5 
1 2 4 8 16

样例输出3复制

2
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include//INT_MAX
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
typedef long long ll;
using namespace std;
const int mod=998244353;  
const int NM=5e3+10;
int n,a[NM],dp[NM][NM],jg;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)	
		cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=2;i<=n;i++){
		for(int j=1;j

计蒜客----训练联盟赛ICPC Yokohama 2018_第3张图片

计蒜客----训练联盟赛ICPC Yokohama 2018_第4张图片

计蒜客----训练联盟赛ICPC Yokohama 2018_第5张图片

计蒜客----训练联盟赛ICPC Yokohama 2018_第6张图片

输出时每行末尾的多余空格,不影响答案正确性

样例输入1复制

5 2 7
1 1
1 2
1 3
2 3
2 4
4 4
5 2

样例输出1复制

9

样例输入2复制

500 500 16
1 1
1 2
1 999
1 1000
2 1
2 2
2 999
2 1000
3 1
3 2
3 999
3 1000
499 500
499 501
499 999
499 1000

样例输出2复制

1008
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include//INT_MAX
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
typedef long long ll;
using namespace std;
const int mod=998244353;  
const int NM=500010;
struct node
{
  int r;
  int c;
  int d;
}G[NM];
bool cmp(node a,node b)
{
    return a.d>b.d;
}
int main()
{
    int r,s,p;
    cin>>r>>s>>p;
    for(int i=0;i>G[i].r>>G[i].c;
        if(G[i].c>s)
            G[i].d=(G[i].c-s)+(r-G[i].r+1);
        else
            G[i].d=(s-G[i].c+1)+(r-G[i].r+1);
    }
    sort(G,G+p,cmp);
    int ct=1,mx=G[0].d;
    for(int i=1;imx)
            mx=G[i].d+ct;
        ct++;
    }
    cout<

你可能感兴趣的:(计蒜客)