## 编程

### 第一题 A了

```#include<iostream>
using namespace std;
int num[300];
int main(){
string s;
cin>>s;
for(int i= s.size()-1;i>=0;i--){
if(num[s[i]]==0)num[s[i]]=i;
}
//    for(int i='a';i<='z';i++){
//        cout<<num[i]<<" "<<i<<endl;
//    }
int flag=0;
for(int i=0;i<s.size();i++){
if(flag==1){
break;
}
if(s[i]=='a')continue;
else{
for(int j='a';j<s[i];j++){

if(num[j]>i){
//cout<<num[j]<<": "<<i<<endl;
flag=1;
s[num[j]]=s[i];
s[i]=j;
cout<<s<<endl;
return 0;
}
}
}
}
cout<<s;
return 0;
}```

### 第二题 过了63%

```#include<iostream>
#include<vector>
#include<set>
using namespace std;
int vv[1005];
int path[100005][2];
int findfa(int a){
if(a!=vv[a]){
vv[a]=findfa(vv[a]);
}return vv[a];
}
int main(){
int t;
cin>>t;
for(int i=0;i<t;i++){
int n,m;
cin>>n>>m;
//vector<vector<int> >node(n,vector<int>(n));
//vector<vector<int> >path(m,vector<int>(2));
//set<int>st;
int flag=1;
for(int i=0;i<m;i++){
int a,b;
cin>>a>>b;
//node[a-1][b-1]=1;
//node[b-1][a-1]=1;
path[i][0]=a-1;
path[i][1]=b-1;
}
for(int i=0;i<m;i++){
int a,b;
//vector<int>vv(n,999);
for(int j=0;j<n;j++){
vv[j]=j;
}
for(int j=0;j<m;j++){
if(flag==0){
break;
}
if(j==i){
continue;
}
a=path[j][0];
b=path[j][1];
int fa = findfa(a);
int fb = findfa(b);
if(fa<fb){
vv[fb]=fa;
//findfa(fb,vv);
}else {
vv[fa]=fb;
//findfa(fa,vv);
}
//cout<<a<<vv[a]<<" "<<b<<vv[b]<<endl;

}
for(int i=0;i<n;i++){
//cout<<findfa(i,vv)<<"  "<<i<<endl;
if(findfa(i)!=0){
flag=0;
}
}
}
if(flag==0){
cout<<"No"<<endl;
}else{
cout<<"Yes"<<endl;
}

}
return 0;
}```
#笔经##滴滴##Java#

2022-12-29 12:27
Durham University_2022

2022-12-07 11:00

2022-12-08 13:52

01-18 16:22

2022-12-15 16:06

2022-12-14 18:10

2022-12-15 14:39

2022-12-07 21:39

2022-12-12 00:43

2022-12-23 14:45

2022-12-31 20:32

3 14 评论