跳到正文

个人记录

8.29(更新版)

huanzhenyang0420约 9 分钟
原文
文章信息与版本

文章信息

发布
2025年8月30日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 9 分钟

版本

  1. v1当前

今日比赛8.29

U594492

赛时代码✔Accepted1̸00tps\color{green}{赛时代码✔}\\ \color{green}{Accepted\not100tps}
C++
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	int n;
	string s;
	cin>>n>>s;
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

U594497

赛时代码✔Accepted1̸00tps\color{green}{赛时代码✔}\\ \color{green}{Accepted\not100tps}
C++
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[10][10];
int main(){
	for(int i=1;i<=8;i++)
		for(int j=1;j<=8;j++){
			cin>>s[i][j];
			if(s[i][j]=='*'){
				cout<<char(j-1+'a')<<8-i+1;
				return 0;
			}
		}
	return 0;
}

U594502

赛时代码✘WrongAnswer8̸0tps\color{red}{赛时代码✘}\\ \color{red}{Wrong Answer\not80tps}
C++
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200005];
int main(){
	ll n,x;
	cin>>n>>x;
	for(ll i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		int y=a[i]-x;
		int pos=upper_bound(a+1,a+n+1,y)-a;
//		cout<<"pos = "<<pos<<endl;
		if(abs(a[i]-a[pos])==x||abs(a[i]-a[pos-1])==x){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}
正确代码✔\color{green}{正确代码✔}
C++
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200005];
int main(){
	ll n,x;
	cin>>n>>x;
	for(ll i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);//排序(因为之后会使用upper_bound)
	for(int i=1;i<=n;i++){//枚举
		int y=a[i]-x;//y是需要从a数组中寻找的数字
		int pos=upper_bound(a+1,a+n+1,y)-a-1;//二分查找第一个≥y的数的下标-1
//		cout<<"pos = "<<pos<<endl;
		if(a[pos]==y){//判断找到的下标所表示的数是否等于需要的数
			cout<<"Yes";//输出
			return 0;//结束这个循环
		}
	}
	cout<<"No";//如果一直没有结束表示不存在输出""No""
	return 0;
}

T638295

赛时代码✘WrongAnswer3̸0tps\color{red}{赛时代码✘}\\ \color{red}{Wrong Answer\not30tps}
C++
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<pair<ll,ll>,ll > a;
int main(){
	ll n,m;
	cin>>n>>m;
	for(ll i=1;i<=m;i++){
		ll x,y;
		cin>>x>>y;
		a[{x,y}]=1;
		a[{x,0}]++;
		a[{y,x}]=1;
		a[{y,0}]++;
	} 
	for(ll i=1;i<=n;i++){
		cout<<a[{i,0}]<<" ";
		for(ll j=1;j<=n;j++)
			if(a[{i,j}]==1)
				cout<<j<<" ";
		cout<<endl;
	}
	return 0;
}
正确代码✔\color{green}{正确代码✔}
C++
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
vector<int>a[N];
int b[N];
int n,m;
int x,y;
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>x>>y;//输入两个城市
        a[x].push_back(y);//建边
        a[y].push_back(x);//建边
    }
    for(int i=1;i<=n;i++){
        cout<<a[i].size()<<' ';//输出长度
        sort(a[i].begin(),a[i].end());//排序
        for(int j=0;j<a[i].size();j++){
            cout<<a[i][j]<<' ';//输出
        }
        cout<<endl;//记得换行
    }
    return 0;
}

U594511

题意分析:

赛时代码✘WrongAnswer0̸tps\color{red}{赛时代码✘}\\ \color{red}{Wrong Answer\not0tps}
C++
此内容已被删除。(详见置顶帖)
C++
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll n;
ll ans=-1;
int len;
void dfs(int u,ll b) {//u:从左到右的第u位 b:二进制数转10进制的结果
    if(ans!=-1) return;//剪枝
    if((b<<(len-u))>n) return;//剪枝(⚠️位运算优先级极低,一定要加括号)
    if(u>=len){
        ans=b;
        return;
    }
    if(s[u]=='?') {
        dfs(u+1,b*2+1);//优先选择1
        dfs(u+1,b*2+0);//再选2
    }else dfs(u+1,b*2+(s[u]-'0'));
}
int main() {
    cin>>s>>n;
    len=s.size();
    dfs(0,0);
    cout<<ans;
    return 0;
}

U594516

C++
此内容已被删除。(详见置顶帖)
C++
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
struct node{
    ll l,d;
}a[N];
ll n,m,p[N],sum;
bool cmp(node x,node y){
    return x.l<y.l;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>p[i];
        sum+=p[i];
    }
    for(int i=1;i<=m;i++){
        cin>>a[i].l;
    }
    for(int i=1;i<=m;i++){
        cin>>a[i].d;
    }
    sort(p+1,p+1+n);
    sort(a+1,a+1+m,cmp);
    priority_queue<ll>q;
    int t=1;
    for(int i=1;i<=n;i++){
        while(t<=m&&a[t].l<=p[i]){
            q.push(a[t].d);
            t++;
        }
        if(q.size()){
            sum-=q.top();
            q.pop();
        }
    }
    cout<<sum;
    return 0;
}
原文