做了四个题。。
A. Vasya And Password
直接特判即可,,为啥泥萌都说难写,,,,
这个子串实际上是忽悠人的,因为每次改一个字符就可以
我靠我居然被hack了????
%……&*()(*&……好吧我把$0$从数字里扔了。
/* */ #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<map> #include<vector> #include<set> #include<queue> #include<cmath> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/hash_policy.hpp> #define Pair pair<int, int> #define MP(x, y) make_pair(x, y) #define fi first #define se second #define int long long #define LL long long #define ull unsigned long long #define rg register #define pt(x) printf("%d ", x); //#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++) //char buf[(1 << 22)], *p1 = buf, *p2 = buf; //char obuf[1<<24], *O = obuf; //void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';} //#define OS *O++ = ' '; using namespace std; //using namespace __gnu_pbds; const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7; const double eps = 1e-9; inline int read() { char c = getchar(); int x = 0, f = 1; while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();} while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } int T; char s[MAXN]; void solve() { int N = strlen(s + 1); int a = 0, b = 0, c = 0; for(int i = 1; i <= N; i++) { if(s[i] >= '0' && s[i] <= '9') a++; if(s[i] >= 'a' && s[i] <= 'z') b++; if(s[i] >= 'A' && s[i] <= 'Z') c++; } if(a == 0) { if(b > 1) { for(int i = 1; i <= N; i++) if(s[i] >= 'a' && s[i] <= 'z') {s[i] = '1'; break;} b--; } else if(c > 1) { for(int i = 1; i <= N; i++) if(s[i] >= 'A' && s[i] <= 'Z') {s[i] = '1'; break;} c--; } } if(b == 0) { if(a > 1) { for(int i = 1; i <= N; i++) if(s[i] >= '0' && s[i] <= '9') {s[i] = 'a'; break;} a--; } else if(c > 1) { for(int i = 1; i <= N; i++) if(s[i] >= 'A' && s[i] <= 'Z') {s[i] = 'a'; break;} c--; } } if(c == 0) { if(a > 1) { for(int i = 1; i <= N; i++) if(s[i] >= '0' && s[i] <= '9') {s[i] = 'A'; break;} a--; } else if(b > 1) { for(int i = 1; i <= N; i++) if(s[i] >= 'a' && s[i] <= 'z') {s[i] = 'A'; break;} b--; } } printf("%s\n", s + 1); } main() { T = read(); while(T--) { scanf("%s", s + 1); solve(); } return 0; } /* 2 2 1 1 1 2 1 1 */