A

link



这道题就先输出整个的\(oox\),再输出剩一个两个的。

点击查看代码
#include<bits/stdc++.h>

using namespace std;

int n;

signed main(){

	cin >> n;

	int t = n/3;
for(int i = 1;i <= t;++ i)
cout << "oox"; if(n%3 == 1) cout << "o";
if(n%3 == 2) cout << "oo"; return 0; }

B

link



可以用二维数组记录每个点到其他各点的距离,再找最小的。

点击查看代码
#include<bits/stdc++.h>

#define int long long

using namespace std;

int n;
int x[105],y[105];
double g[105][105]; signed main(){ cin >> n;
for(int i = 1;i <= n;++ i)
cin >> x[i] >> y[i]; for(int i = 1;i <= n;++ i){
for(int j = 1;j < i;++ j){
g[i][j] = sqrt((x[i]-x[j])*(x[i]-x[j])
+(y[i]-y[j])*(y[i]-y[j]));
g[j][i] = g[i][j];
}
} for(int i = 1;i <= n;++ i){
double mx =-1e6;
for(int j = 1;j <= n;++ j)
if(i != j) mx = max(mx,g[i][j]);
for(int j = 1;j <= n;++ j){
if(abs(g[i][j]-mx) <= 1e-6&&i != j){
cout << j << endl;
break;
}
}
} return 0; }

C

link



这个题也不难。

把每个颜色中的最小值存下来,再从这些中取最大值。

判断这个颜色之前出没出现过,新建一个位置,否则再原来的位置上再取\(min\)。

点击查看代码
#include<bits/stdc++.h>

#define int long long

using namespace std;

int n,c[200005],tp;
map<int,int> mp; signed main(){ cin >> n;
for(int i = 1;i <= n;++ i){
int a,cc;
cin >> a >> cc;
if(mp[cc]) c[mp[cc]] = min(c[mp[cc]],a);
else mp[cc] = ++tp,c[mp[cc]] = a;
} int ans = 0;
for(int i = 1;i <= tp;++ i)
ans = max(ans,c[i]); cout << ans; return 0; }

D

link



一个普普通通的广搜。

点击查看代码
#include<bits/stdc++.h>

using namespace std;

int h,w;
int a[205][205];
int n;
int r,c,e;
int sx,sy,tx,ty;
int eng[205][205];
int le[205][205];
int dx[] = {0,0,0,1,-1};
int dy[] = {0,1,-1,0,0}; struct nd{
int x,y;
}; signed main(){ cin >> h >> w;
for(int i = 1;i <= h;++ i)
for(int j = 1;j <= w;++ j){
char ch;
cin >> ch;
if(ch == '.')a[i][j] = 0;
if(ch == '#')a[i][j] = 1;
if(ch == 'S')a[i][j] = 0,sx = i,sy = j;
if(ch == 'T')a[i][j] = 0,tx = i,ty = j;
}
cin >> n;
for(int i = 1;i <= n;++ i){
cin >> r >> c >> e;
eng[r][c] = e;
} if(eng[sx][sy] == 0){
cout << "No";
return 0;
} queue<nd> q;
q.push({sx,sy});
le[sx][sy] = eng[sx][sy];
while(!q.empty()){
int x = q.front().x;
int y = q.front().y;
q.pop();
for(int i = 1;i <= 4;++ i){
int xx = x+dx[i];
int yy = y+dy[i];
if(a[xx][yy] == 1) continue;
if(xx <= 0||yy <= 0||xx > h||yy > w)
continue;
if(max(le[x][y]-1,eng[xx][yy]) > le[xx][yy]){
q.push({xx,yy});
le[xx][yy] = max(le[x][y]-1,eng[xx][yy]);
}
if(xx == tx&&yy == ty){
cout << "Yes";
return 0;
}
}
} cout << "No"; return 0; }

E

link

随机推荐

  1. Python爬取数据并保存到csv文件中

    1.数据源 2.Python代码 import requests from lxml import etree import csv url = 'http://211.103.175.222:508 ...

  2. Django——基于forms组件和ajax的注册功能

    path('register/',views.register) #注册的form表单 from django import forms from django.forms import widget ...

  3. 7z 命令行压缩解压详解-中文版

    1) 简介 7z,全称7-Zip, 是一款开源软件.是目前公认的压缩比例最大的压缩解压软件. 主页:http://www.7-zip.org/ 中文主页:http://7z.sparanoid.com ...

  4. docker安装Kafka(windows版)

    windows环境安装docker参考安装docker桌面版(Windows) 这一步如果出现报错的话可以直接输入wsl -l -v命令来查看当前Ubuntu的wsl版本 安装Kafka需要先安装 z ...

  5. 使用kubadm部署一套k8s学习平台环境

    使用kubeadm部署k8s集群 环境 IP地址 主机名 节点 10.0.0.63 k8s-master1 master1 10.0.0.63 k8s-master2 master2 10.0.0.6 ...

  6. openstack考试需要的部署操作

    openstack操作大全 一,keystone 用户 1.创建用户 openstack user create --password 密码 --email邮箱 --domain 域名 用户名字 2. ...

  7. Adobe软件资源 PS PR AE等等

    整理了一波Adobe软件,19年20年21年Mac版本的都有,关注Rand_cs即可领取

  8. 基于 Easysearch kNN 搭建即时图片搜索服务

    环境准备 启动 Easysearch 服务: # Make sure your vm.max_map_count meets the requirement sudo sysctl -w vm.max ...

  9. Prometheus 聚合查询的两个方案

    问题背景 多个 Prometheus 集群或者多个 VictoriaMetrics 集群,在 Grafana 和夜莺里通常需要创建多个不同的数据源,这也就意味着,数据没法聚合查询,比如统一做一下 su ...

  10. MySQL BETWEEN AND包含边界值

    select count(1) from table_a where my_date between '20230715' and '20230717'; 上面的SQL我们发现只统计了20230715 ...