
Lv.1
大家好
签名:oier退役 moer现役 备考高考/mc/星铁
在 【社区里谁会C++】 中回复
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
vector<int> h[N],c[N];
int dis[N];
void SPFA(int s){
memset(dis,0x3f,sizeof(dis));
dis[s]=0;
queue<int> q;
q.push(s);
while(!q.empty()){
int x=q.front();q.pop();
for(int i=0;i<(int)h[x].size();i++){
int u=h[x][i];
if(dis[u]>dis[x]+c[x][i]){
dis[u]=dis[x]+c[x][i];
q.push(u);
}
}
}
}
int main(){
h[0].push_back(1);
c[0].push_back(1);
h[1].push_back(5);
c[1].push_back(2);
h[0].push_back(5);
c[0].push_back(0);
SPFA(0);
printf("%d",dis[5]?"我不会C++!":"我会C++!");
return 0;
}2022-08-15T20:34:33 点赞:1
在 【瓢虫新图】新图投票!!地图内容由你来定!!! 中回复
1、深海对决重置 4票
2、奇趣地球村重置 7票
3、昆虫PVP 2票
4、房间成精 6票
5、食物岛大战 1票
2022-08-24T20:18:31 点赞:0
在 C++下标大小写互换 中回复
首先 楼主的代码稍微有一点问题
namespace std
{
string bl(string in)
{
for(int i=0;i<in.size();i++)
{
if(in[i]>=97&&in[i]<=122)
{
in[i]-=32;
}
}
return in;
}
string ll(string in)
{
for(int i=0;i<in.size();i++)
{
if(in[i]>=65&&in[i]<=90)
{
in[i]+=32;
}
}
return in;
}
}
同时 不建议想楼主一样把函数直接写到std里()
2022-08-27T18:05:09 点赞:0
在 【请问此C++代码哪里错了】 中回复
大屑MX太懒了,不想调代码 写了份新代码不知道对你有没有用(同一道题 应该没问题
#include <bits/stdc++.h>
using namespace std;
int ts;
struct node
{
bool st[30];
node operator+(const node &B)
{
node tmp;
for(int i = 0; i < 26; i++)
{
tmp.st[i] = st[i] || B.st[i];
}
return tmp;
}
node operator-(const node &B)
{
node tmp;
for(int i = 0; i < 26; i++)
{
tmp.st[i] = st[i] && (!B.st[i]);
}
return tmp;
}
node operator*(const node &B)
{
node tmp;
for(int i = 0; i < 26; i++)
{
tmp.st[i] = st[i] && B.st[i];
}
return tmp;
}
}de;
void solve()
{
string as,bs,op;
node a, b, c;
for(int i = 0; i < 26; i++) a.st[i] = 0, b.st[i] = 0, c.st[i] = 0;
cin>>as>>op>>bs;
for(int i=0;i<as.size();i++){
a.st[as[i]-'a']=1;
}
for(int i=0;i<bs.size();i++){
b.st[bs[i]-'a']=1;
}
if(op == "+") c = a + b;
else if(op == "-") c = a - b;
else if(op == "*") c = a * b;
for(int i = 0; i < 26; i++)
if(c.st[i]) printf("%c", i + 'a');
}
int main()
{
int t;
scanf("%d", &t);
while(t--) solve();
return 0;
}2022-08-27T18:33:26 点赞:0
在 问题求助,有点急(周末有时间) 中回复
https://docs.box3.codemao.cn/box3raycastoptions.html?h=Raycast
2022-11-19T07:57:16 点赞:0