【CodeForces】Hello2020

HELLO 2020

好久没有敲代码了,2020第一场 $Codeforces$

太弟弟了,$2500+rank$ ,还有半小时,放弃了,估计还得掉几百名。

A

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<bits/stdc++.h>
using namespace std;

//一个多月没有敲代码

int n, m;

int main() {
cin >> n >> m;
vector<string>N, M;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
N.push_back(s);
}
for (int i = 0; i < m; i++) {
string s;
cin >> s;
M.push_back(s);
}
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int t; cin >> t;
cout << N[(t - 1) % n] << M[(t - 1) % m] << endl;
}
}

B

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<bits/stdc++.h>
#define int long long
using namespace std;

int up[100010];
int down[100010];
int cnt;
signed main(){
int n;
cin >> n;
int sum = 0;
for(int i= 0 ;i < n;i++){
int m;cin >> m;
int flag = 0;
int A[m+1];
int Min = 0x3f3f3f3f;
int Max = -Min;
for(int i = 0;i < m;i++){
cin >> A[i];
Min = min(Min,A[i]);
Max = max(Max,A[i]);
if(i > 0 && A[i] > A[i-1]){
flag = 1;
}
}
if(flag == 1){
sum += n;
}
else{
up[cnt] = Max;
down[cnt++] = Min;
}
}
sort(down,down+cnt);
for(int i = 0;i < cnt;i++){
int ind = (lower_bound(down,down+cnt,up[i]) - down);
if(ind != cnt){
sum += ind;
}
}
cout << sum << endl;
}

C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<bits/stdc++.h>
#define int long long
using namespace std;

int fac[250050];
int n, m;
void init() {
fac[0] = 1;
for (int i = 1; i <= n; i++) {
fac[i] = fac[i - 1] * i % m;
}
}
signed main() {
scanf("%lld%lld", &n, &m);
init();
int res = 0;
for (int i = 1; i <= n; i++) {
//cout << i * i * fac[i - 1] % m * fac[n - i + 1] % m << endl;
res += i * i % m * fac[i - 1] % m * fac[n - i + 1] % m;
res %= m;
}
printf("%lld\n", res);

}