过了五题,友好度++

想着补完第六题再来,又鸽了

F题dfs做爆MLE

A题按题意将差的绝对值相加即可

B题找规律,每4步都会回到原地,然后按原点奇偶分类讨论

C题,先将数排序,注意到每次操作中都会将前一次消去,所以只需维护排序后的两数之差即可,需要留意的是这个初始情况

D题,考虑最坏情况,蓝色数填满,红色数填满。于是只需判断蓝色数是不是均大于等于自身索引,红色数字是不是均小于等于减去自身索引

E题按题意模拟,模拟到break后撤销操作,然后输出答案


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
LL t;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>t;
f(sb,1,t){
map<char,int> m;
string s;
cin>>s;
f(i,0,25){
m[s[i]]=i+1;
}
cin>>s;
auto it=s.begin();
it++;
LL ans=0;
while(it!=s.end()){
ans+=abs(m[(*it)]-m[(*(it-1))]);
it++;
}
cout<<ans<<"\n";
}
return 0;
}

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
LL tt,n,a;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>tt;
f(sb,1,tt){
cin>>n>>a;
if(n&1){
int t=a%4;
if(t==1){
n+=a;
}
else if(t==2){
n-=1;
}
else if(t==3){
n-=(a+1);
}
}
else {
int t=a%4;
if(t==1){
n-=a;
}
else if(t==2){
n+=1;
}
else if(t==3){
n+=(a+1);
}
}
cout<<n<<"\n";
}
return 0;
}

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
25
26
LL t,n,te;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>t;
f(b,1,t){
vi v;
cin>>n;
f(i,1,n){
cin>>te;
v.pb(te);
}
sort(all(v));
auto it =v.begin();
LL ans=(*it);
it++;
while(it!=v.end()){
ans=max(ans,(*it)-(*(it-1)));
it++;
}
cout<<ans<<"\n";
}
return 0;
}

D:

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
43
44
45
46
47
48
49
50
51
52
53
54
55
LL t,n;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>t;
f(sb,1,t){
cin>>n;
vi a,b,r;
f(i,1,n){
LL temp;
cin>>temp;
a.pb(temp);
}
string s;
cin>>s;
LL cnt=0;
for(auto it:s){
if(it=='B') b.pb(a[cnt]);
else r.pb(a[cnt]);
cnt++;
}
sort(all(b));
sort(rall(r));
bool ok=1;
LL lb=b.size(),lr=r.size();
if(ok&&lb){
LL tt=1;
for(auto it:b){
if(it<tt)
{
ok=0;
break;
}
tt++;
}
}
// cout<<ok;
if(ok&&lr){
LL tt=n;
for(auto it:r){
//cout<<"\n::"<<it<<tt;
if(it>tt){
ok=0;
break;
}
tt--;
}
}
if(ok) cout<<"YES\n";
else cout<<"NO\n";
}
return 0;
}

E:

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
43
44
45
LL t,n,m;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>t;
f(sb,1,t){
cin>>n>>m;
string s;
cin>>s;
f(i,2,n){
string temp;
cin>>temp;
s+=temp;
}
LL r,c,rz,rf,cz,cf;
r=c=rz=rf=cz=cf=0;
LL cnt=0;
for(auto it:s){
cnt+=1;
if(it=='L') c-=1;
if(it=='R') c+=1;
if(it=='U') r-=1;
if(it=='D') r+=1;
//cout<<c<<"::"<<r<<"\n";
if(c<0) cf=max(cf,-c);
else cz=max(cz,c);
if(r<0) rf=max(rf,-r);
else rz=max(rz,r);
if(cf+cz+1>m||rz+rf+1>n){
if(it=='L') cf-=1;
if(it=='R') cz-=1;
if(it=='U') rf-=1;
if(it=='D') rz-=1;
break;
}
if((cf||cz||rf||rz)&&c==0&&r==0)
break;
}
//cout<<rz<<"MJij";
cout<<(n-rz)<<" "<<(m-cz)<<" "<<cnt<<"\n";
}
return 0;
}

太懒太菜了

洛谷P2548,一开始竟然想着字符串哈希比较。。。无语;;;

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <algorithm>
#include <bitset>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <cmath>
/*
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
*/
using namespace std;

const double eps = 1e-10;
const double pi = 3.1415926535897932384626433832795;
const double eln = 2.718281828459045235360287471352;

#define f(i, a, b) for (int i = a; i <= b; i++)
#define LL long long
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
#define scan(x) scanf("%d", &x)
#define mp make_pair
#define pb push_back
#define sqr(x) (x) * (x)
#define pr1(x) printf("Case %d: ", x)
#define pn1(x) printf("Case %d:\n", x)
#define pr2(x) printf("Case #%d: ", x)
#define pn2(x) printf("Case #%d:\n", x)
#define lowbit(x) (x & (-x))

#define fi first
#define se second
#define sz(x) int((x).size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define summ(a) (accumulate(all(a), 0ll))

typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

bitset<106> vis;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
vis.reset();
LL n, m;
cin >> n >> m;
vector<string> v(n);
f(i, 1, n)
{
cin>>v[i-1];
}
f(i,1,m-1){
f(j,1,n){
string temp;
cin>>temp;
if(temp!=v[j-1])
vis[j-1]=1;
}
}
f(i,0,n-1){
if(vis[i])
cout<<"* ";
else cout<<v[i]<<" ";
}
return 0;
}

终于到pupil了。。。

菜鸡


用github上的CFRatingColor搭了个rating card
1
https://www.ilyh.cc/rating.php?user=

智商在线检测round。。。

A题维护的最大值。

B题,先判断是否为偶数,不是的话就判断是否存在,不存在就是NO,否则为YES

C题,判断中是否存在,使得,不存在就为NO,不知为何偷懒只判断前14位全排列会WA

D题, 的情况就直接输出

下面讨论,的情况,不妨设显然为偶数,那么取,则有


A

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
LL t;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>t;
f(sb,1,t){
LL n,ans=0;
cin>>n;
f(i,1,n){
LL temp;
cin>>temp;
ans=max(ans,temp-i);
}
cout<<ans<<"\n";
}
return 0;
}

B:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
LL t,n,last,now,flag;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>t;
f(sb,1,t){
cin>>n;
flag=(n&1)?0:1;
cin>>last;
f(i,2,n){
cin>>now;
if(last>=now)
flag=1;
last=now;
}
if(flag) cout<<"YES\n";
else cout<<"NO\n";
}
return 0;
}

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
25
26
27
28
29
30
31
32
33
34
35
36
LL t, n, temp, a[18];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> t;
a[1] = 1;
f(i, 2, 17) a[i] = i * a[i - 1];
f(sb, 1, t)
{
cin >> n;
LL flag = 1;
f(i, 1, n)
{
cin >> temp;
LL dd = 0;
if (flag)
f(j, 2, i + 1)
{
if (temp % j)
{
dd = 1;
break;
}
}
if (dd == 0)
flag = 0;

}
if (flag)
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}

D:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>t;
f(sb,1,t){
cin>>x>>y;
if(y<x) cout<<x+y<<"\n";
else if(x==y) cout<<x<<"\n";
else if(((x+y)>>1)%x==y%((x+y)>>1))cout<<((x+y)>>1)<<"\n";
else {
LL m=y-x;
m=m/x*x;
x+=m;
cout<<((x+y)>>1)<<"\n";
}
}
return 0;
}

躺了好久
鸽

0%