【codeforces】一切为了上分:骚操作合集

今早一看 稳在了青名(别骂我菜
似乎能够往蓝名看齐了。继续加油。
B. Putting Bricks in the Wall
大意:起点和终点附近有四个格子。要保证起点附近的两个格子都是1或都是0;同时终点附近的两个格子都是0或都是1.(起点和终点的格子不一样。)输出修改操作次数,和哪些格子要修改。

漂亮的模式化代码:

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define V std::vector<int>
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
#define INF 0x3f3f3f3f
#define lowbit(x) ((x)&-(x))
#define MOD 1000000007
const int N=1e5+5;
int T,n,res;
char s[210][210];

bool check(char x,char y){
    res=(s[1][2]==y)+(s[2][1]==y)+(s[n][n-1]==x)+(s[n-1][n]==x);
    if(res<=2){
        printf("%d\n",res);
        if(s[1][2]==y) printf("1 2\n");
        if(s[2][1]==y) printf("2 1\n");
        if(s[n][n-1]==x) printf("%d %d\n",n,n-1);
        if(s[n-1][n]==x) printf("%d %d\n",n-1,n);
        return 1;
    }
    return 0;
}
int main(){
    scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        FOR(i,1,n) scanf("%s",s[i]+1);
        if(check('0','1'));
        else check('1','0');
    }
}

漂亮的模式化代码2:
D. Hexagons
非常完美地将所有方向的多样性统一化。

t=int(input())
for i in range(t):
    x,y=map(int,input().split())
    c=list(map(int,input().split()))
    
    path1=abs(x)*c[0 if x>=0 else 3]+abs(y-x)*c[1 if y-x>=0 else 4]
    path2=abs(y)*c[0 if y>=0 else 3]+abs(x-y)*c[5 if x-y>=0 else 2]
    path3=abs(y)*c[1 if y>=0 else 4]+abs(x)*c[5 if x>=0 else 2]
    
    print(min(path1,path2,path3))

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值