Submission #3600166
Source Code Expand
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define dump(x) cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};
// https://beta.atcoder.jp/contests/abc076/tasks/abc076_c
int main() {
string S, T; cin >> S >> T;
if (S.length() < T.length()) {
cout << "UNRESTORABLE" << "\n";
return 0;
}
string ans = "~";
REP(i, S.length() - T.length() + 1) {
string sub = S.substr(i, T.length());
bool can = true;
REP(j, T.length()) {
if (sub[j] != T[j] && sub[j] != '?') can = false;
}
if (can) {
string p = S;
REP(k, T.length()) {
p[i+k] = T[k];
}
REP(k, S.length()) {
if (p[k] == '?') p[k] = 'a';
}
ans = min(p, ans);
}
}
if (ans == "~") {
cout << "UNRESTORABLE" << "\n";
} else {
cout << ans << "\n";
}
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Dubious Document 2 |
User |
wakamenod |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1986 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
s1.txt, s2.txt |
All |
in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, s1.txt, s2.txt |
Case Name |
Status |
Exec Time |
Memory |
in01.txt |
AC |
1 ms |
256 KB |
in02.txt |
AC |
1 ms |
256 KB |
in03.txt |
AC |
1 ms |
256 KB |
in04.txt |
AC |
1 ms |
256 KB |
in05.txt |
AC |
1 ms |
256 KB |
in06.txt |
AC |
1 ms |
256 KB |
in07.txt |
AC |
1 ms |
256 KB |
in08.txt |
AC |
1 ms |
256 KB |
in09.txt |
AC |
1 ms |
256 KB |
in10.txt |
AC |
1 ms |
256 KB |
in11.txt |
AC |
1 ms |
256 KB |
in12.txt |
AC |
1 ms |
256 KB |
s1.txt |
AC |
1 ms |
256 KB |
s2.txt |
AC |
1 ms |
256 KB |