标签:problem 要求 har show img == tin put 输出
#include<cstdio>
#include<iostream>
using namespace std;
const int N = 1000;
int du[N],e[N][N],ji[N],ans[N*10],ansjs;
char c[5];
void dfs(int u) {
for(int i = 'A';i <= 'z';++i) {
if(!e[u][i]) continue;
e[u][i]--;
e[i][u]--;
dfs(i);
}
ans[++ansjs]=u;
}
int main() {
int n;
scanf("%d",&n);
for(int i = 1;i <= n;++i) {
scanf("%s",c+1);
e[int(c[1])][int(c[2])]++;
e[int(c[2])][int(c[1])]++;
du[int(c[1])]++;
du[int(c[2])]++;
}
int js=0;
for(int i = 'A';i <= 'z';++i) if(du[i]&1) ji[++js]=i;
if(js != 0 && js != 2) {
puts("No Solution");
return 0;
}
int s=1000;
for(int i = 'A';i <= 'z';++i) {
if(!du[i]) continue;
if(js == 0) s=min(s,i);
else if(du[i]&1) s=min(s,i);
}
dfs(s);
for(int i = ansjs;i >= 1;--i)
printf("%c",ans[i]);
return 0;
}
标签:problem 要求 har show img == tin put 输出
原文地址:https://www.cnblogs.com/wxyww/p/9787198.html