Problem:
Problem B: Yu-kun Likes Letters in the English Alphabet
Background
会津大学付属幼稚園はプログラミングが大好きな子供が集まる幼稚園である。園児の一人であるゆう君は、プログラミングと同じくらい英小文字が大好きだ。
そんなゆう君は紙と丸と線、そして英小文字を使う新しい遊びを考え、その採点用プログラムを書くことにした。
Problem
初期状態として、紙に
V
個の丸と
E
本の線が書かれている。丸には0から昇順に番号がつけられており、各丸の中には英小文字が1つ書かれているか、何も書かれていない。 各線は異なる２つの丸を結んでいる。1つの丸が26本以上の線で結ばれることはない。
遊びの手順は以下の通りである。
何も書かれていない丸を１つ選ぶ。 そのような丸が存在しない場合はこの処理を終了する。
丸の中に英小文字を１つ書く。　ただし丸が既に英小文字の書かれている丸と線で結ばれている場合、その英小文字と同じ英小文字は書くことはできない。
1. に戻る。
上記の手順に従って全ての丸に英小文字を書いた後、丸の番号が小さい順に丸の中の英小文字を並べ文字列を作る。
こうしてできる文字列を辞書順で最小となるようにしたい。
２つの同じ長さの文字列
s
,
t
があり、
s
が
t
より辞書順で小さいとは次のような場合を言う。
s
i
は文字列
s
の
i
番目の英小文字を、
t
i
は文字列
t
の
i
番目の英小文字を表す。
s
i
が
t
i
と異なるような最小の
i
について、
s
i
が
t
i
より小さい。
紙の初期状態が与えられるので、そこから上記の手順にしたがって作成できる文字列のうち辞書順最小のものを出力せよ。
Input
V
E
a
0
a
1
...
a
(V-1)
s
0
t
0
s
1
t
1
...
s
(E-1)
t
(E-1)
１行目に丸の数
V
と線の数
E
が空白区切りで与えられる。
２行目に丸の初期状態が空白区切りで与えられる。
a
i
が英小文字の場合は
i
番目の丸にその英小文字が書かれており、'?'の場合は
i
番目の丸には何も書かれていないことを表す。
続く
E
行に線の情報が
s
i
t
i
として与えられ、これは
s
i
番の丸と
t
i
番の丸が線で結ばれていることを表す。
Constraints
入力は以下の条件を満たす。
1 ≤
V
≤ 100,000
0 ≤
E
≤ 200,000
a
i
は英小文字, または '?' のいずれか ( 0 ≤
i
≤
V-1
)
0 ≤
s
i
,
t
i
≤
V-1
(
s
i
<
t
i
, 0 ≤
i
≤
E-1
)
１つの丸が26本以上の線で結ばれることはない
Output
問題文中の手順に従って作成可能な文字列のうち、辞書順で最も小さいものを1行に出力せよ
Sample Input 1
3 3
c ? ?
0 1
0 2
1 2
Sample Output 1
cab
Sample Input 2
3 2
c ? ?
0 1
0 2
Sample Output 2
caa
Sample Input 3
7 6
? a ? ? z a ?
0 1
0 2
3 4
4 5
4 6
5 6
Sample Output 3
baaazab
Sample Input 4
5 0
? ? ? ? ?
Sample Output 4
aaaaa

Submitted solutions:

code_snippet: #include <iostream>
#include <vector>
using namespace std;

int N;
int M, A[1 << 18], B[1 << 18];
char C[1 << 18];
vector<int> G[1 << 18];

int main() {
	// Step 1. Input
	cin >> N >> M;
	for (int i = 1; i <= N; i++) cin >> C[i];
	for (int i = 1; i <= M; i++) cin >> A[i] >> B[i];
	for (int i = 1; i <= M; i++) A[i] += 1;
	for (int i = 1; i <= M; i++) B[i] += 1;
	for (int i = 1; i <= M; i++) {
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	}

	// Step 2. Greedy
	for (int i = 1; i <= N; i++) {
		if (C[i] != '?') continue;
		vector<bool> used(26, false);
		for (int j : G[i]) {
			if (C[j] == '?') continue;
			int val = (C[j] - 'a');
			used[val] = true;
		}
		for (int j = 0; j < 26; j++) {
			if (used[j] == true) continue;
			C[i] = ('a' + j);
			break;
		}
	}

	// Step 3. Output
	for (int i = 1; i <= N; i++) cout << C[i];
	cout << endl;
	return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 15928
final_rank: 9

code_snippet: #include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
using namespace std;
vector<int> g[100002];
vector<char> vec;
int dp[100002][27];

int main() {
	memset(dp,0,sizeof(dp));
	int n,m;
	cin>>n>>m;
	
	for(int i=0;i<n;i++){
		char c;
		cin>>c;
		vec.push_back(c);
	}
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		g[min(x,y)].push_back(max(x,y));
	}
	for(int i=0;i<n;i++){
		char c1;
		if(vec[i]=='?'){
			for(int j=0;j<g[i].size();j++){
				char c2=vec[g[i][j]];
				if(c2!='?'){
					dp[i][c2-'a']=1;
				}
			}
			for(int j=0;j<26;j++){
				if(dp[i][j]==0){
					vec[i]='a'+j;
					break;
				}
			}
			c1=vec[i];
		}else{
			c1=vec[i];
		}
		int c2=c1-'a';
		for(int j=0;j<g[i].size();j++){
			dp[g[i][j]][c2]=1;
		}
	}
	for(int i=0;i<n;i++){
		cout<<vec[i];
	}
	cout<<endl;
	return 0;
	
}
accuracy: 1
time_ms: 90
memory_kb: 19624
final_rank: 13

code_snippet: #include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/

vector<int> Edge[100005];
int check[100005][30];

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int V,E;
	cin >> V >> E;
	vector<char> A(V);
	string alpha = "abcdefghijklmnopqrstuvwxyz";
	for (int i = 0; i < V; i++)
	{
		cin >> A[i];
		if(A[i] != '?'){
			check[i][A[i]-'a'] = 1;
		}
	}
	
	for (int i = 0; i < E; i++)
	{
		int s,t;
		cin >> s >> t;
		Edge[s].push_back(t);
		Edge[t].push_back(s);
	}
	
	for (int i = 0; i < V; i++)
	{
		//今見ている頂点
		if(A[i] != '?')continue;
		for(auto letter:alpha){
			//埋め込むアルファベットの候補
			bool flag = true;
			if(check[i][letter-'a'])continue;
			for(auto nearId:Edge[i]){
				//周囲に既に使われていないかの確認
				//nearIdはインデックス番号
				if(check[nearId][letter-'a']){
					flag = false;
					break;
				}
			}
			
			if(flag){
				//cout << "i= " << i << " letter= " << letter << endl;
				//letterは使用可能
				check[i][letter-'a'] = 1;
				A[i] = letter;	
				/*for(auto nearId:Edge[i]){
					check[nearId][letter-'a'] = 1;
				}*/
				break;
			}
		}
	}
	for (int i = 0; i < V; i++)
	{
		cout << A[i];
	}
	
	cout << endl;
	return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 21792
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/

int main()
{
    int v, e;
    string s;
    cin >> v >> e;
    rep(i, v)
    {
        char hoge;
        cin >> hoge;
        s.push_back(hoge);
    }
    map<int, set<int>> a;
    rep(i, e)
    {
        int x, y;
        cin >> x >> y;
        a[x].insert(y);
        a[y].insert(x);
    }
    rep(i, s.size())
    {
        set<char> hoge;
        rep(k, 26)
        {
            hoge.insert('a' + k);
        }
        if (s[i] != '?')
            continue;
        else
        {
            for (auto itr = a[i].begin(); itr != a[i].end(); itr++)
            {
                hoge.erase(s[*itr]);
            }
            s[i] = *hoge.begin();
        }
    }
    cout << s << endl;
    return 0;
}
accuracy: 1
time_ms: 370
memory_kb: 31152
final_rank: 18

code_snippet: /*
Dear ToM,
Congratulations on your graduation!
You did a great job!
     ☆ﾟ*＠*ﾟ☆
　　(＠*｡☆｡*＠
　 /☆｡*＠ﾟ*☆
▲/／｡＠｡*☆＠*
　▼―ｰ｡*＠ﾟ*☆
*/

#include <bits/stdc++.h>
using namespace std;

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

int main(){
	ll v, e;
	cin >> v >> e;
	vector<vector<int>> g(v);
	char cs[v];
	rep(i, v){
		cin >> cs[i];
	}
	rep(i, e){
		int s, t;
		cin >> s >> t;
		g[s].push_back(t);
		g[t].push_back(s);
	}

	rep(i, v){
		if(cs[i] != '?') continue;
		vector<bool> f(26, true);
		rep(j, (int)g[i].size()){
			if(cs[g[i][j]] == '?') continue;
			f[cs[g[i][j]] - 'a'] = false;
		}
		rep(j, (int)f.size()){
			if(f[j]){
				cs[i] = char('a' + j);
				break;
			}
		}
	}

	rep(i, v) cout << cs[i];
	cout << endl;

	return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 9760
final_rank: 8

code_snippet: #include<bits/stdc++.h>
using namespace std;

using i64 = int64_t;

int main(){
    int V, E;
    cin >> V >> E;
    vector<char> v;
    for(int i=0;i<V;++i){
        char a;
        cin >> a;
        v.push_back(a);
    }
    vector<vector<int>> graph(V, vector<int>());
    for(int i=0;i<E;++i){
        int s, t;
        cin >> s >> t;
        graph[s].push_back(t);
        graph[t].push_back(s);
    }
    for(int i=0;i<V;++i){
        if(v[i] != '?')continue;
        set<char> st;
        for(auto to: graph[i]){
            if(v[to] == '?')continue;
            st.insert(v[to]);
        }
        char c = 'a';
        while(st.count(c))c++;
        v[i] = c;
    }
    for(auto e: v)cout << e;
    cout << endl;

    return 0;
}
accuracy: 1
time_ms: 100
memory_kb: 9640
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<ll,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

int V, E;
vector<vector<int> > g;
vector<char> ch;

bool solve(){
    cin >> V >> E;
    g.resize(V);
    ch.resize(V);
    for(int i=0;i<V;i++){
        cin >> ch[i];
    }
    for(int i=0;i<E;i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<bool> used(26);
    for(int i=0;i<V;i++){
        if(ch[i] != '?') continue;
        fill(used.begin(),used.end(),false);
        for(auto j : g[i]){
            if(ch[j]=='?') continue;
            used[ch[j]-'a'] = true;
        }
        for(int j=0;j<26;j++){
            if(!used[j]){
                ch[i] = char('a'+j);
                break;
            }
        }
    }
    for(auto c: ch){
        cout << c;
    }
    cout << endl;
    return false;
}

int main(){
    solve();
    // while(!solve());
    // int t; cin >> t; for(;t>0;t--) solve();
    return 0;
}
accuracy: 1
time_ms: 100
memory_kb: 9704
final_rank: 12

code_snippet: #include<iostream>
#include<vector>
using namespace std;

int main(){
    int n, e;
    cin >> n >> e;
    vector<char> c(n);
    for(int i = 0; i < n; i++) cin >> c[i];
    vector<int> v[n];
    while(e-- > 0){
	    int x, y;
	    cin >> x >> y;
	    v[x].push_back(y);
	    v[y].push_back(x);
    }
    for(int i = 0; i < n; i++){
	    if(c[i] != '?')	continue;
	    bool used[26] = {};
	    for(int j : v[i]){
	        if(c[j] != '?')	used[c[j]-'a'] = true;
	    }
	    for(int j = 0; j < 26; j++){
	        if(!used[j]){
		        c[i] = (char)('a' + j);
		        break;
	        }
        }
    }
    for(int i = 0; i < n; i++)	cout << c[i];
    cout << endl;
    return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 9644
final_rank: 7

code_snippet: #include <bits/stdc++.h>

int main()
{
	int V, E;
	scanf("%d%d", &V, &E);
	std::vector<std::list<int>> graph(V);
	std::vector<char> chara(V);
	for (auto& e: chara) scanf(" %c", &e);

	for (int i{}; i < E; i++)
	{
		int s, t;
		scanf("%d%d", &s, &t);
		graph[s].push_back(t);
		graph[t].push_back(s);
	}
	for (int i{}; i < V; i++)
	{
		if (chara[i] != '?') continue;
		bool table[26]{};
		for (auto& e: graph[i])
			if (chara[e] != '?')
				table[chara[e] - 'a'] = true;
		for (int j{}; j < 26; j++)
			if (!table[j])
			{
				chara[i] = 'a' + j;
				break;
			}
	}
	for (auto& e: chara) putchar(e);
	putchar('\n');

	return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 17056
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100000;
vector<int> G[N];

int main(){
    int n,m;
    cin >>n >>m;
    vector<char> a(n);
    rep(i,n) cin >>a[i];
    rep(i,m){
        int u,v;
        cin >>u >>v;
        G[u].pb(v);
        G[v].pb(u);
    }

    rep(i,n){
        if(a[i]=='?'){
            vector<bool> used(26);
            for(int j:G[i]){
                if(a[j]!='?') used[a[j]-'a'] = true;
            }

            a[i] = 'a';
            while(used[a[i]-'a']) ++a[i];
        }
        cout << a[i];
    }
    cout << "\n";
    return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 9916
final_rank: 10

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

struct Node{

	char ch;
	vector<int> ADJ;
};

int V,E;
bool check[26];
char buf[2];
Node nodes[NUM];


int main(){

	scanf("%d %d",&V,&E);

	for(int i = 0; i < V; i++){

		scanf("%s",buf);
		nodes[i].ch = buf[0];
	}

	int from,to;

	for(int loop = 0; loop < E; loop++){

		scanf("%d %d",&from,&to);
		nodes[from].ADJ.push_back(to);
		nodes[to].ADJ.push_back(from);
	}

	for(int i = 0; i < V; i++){

		if(nodes[i].ch != '?'){

			printf("%c",nodes[i].ch);

		}else{

			for(int k = 0; k < 26; k++){

				check[k] = false;
			}

			for(int k = 0; k < nodes[i].ADJ.size(); k++){

				if(nodes[nodes[i].ADJ[k]].ch != '?'){

					check[nodes[nodes[i].ADJ[k]].ch-'a'] = true;
				}
			}

			for(int k = 0; k < 26; k++){

				if(!check[k]){
					nodes[i].ch = 'a'+k;
					printf("%c",nodes[i].ch);
					break;
				}
			}
		}
	}

	printf("\n");

	return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 10732
final_rank: 1

code_snippet: /*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_VN = 100000;
const int MAX_EN = 200000;

/* typedef */

typedef vector<int> vi;

/* global variables */

int as[MAX_VN];
bool used[MAX_VN][26];
vi nbrs[MAX_VN];

/* subroutines */

/* main */

int main() {
  int vn, en;
  cin >> vn >> en;

  for (int i = 0; i < vn; i++) {
    char ai;
    cin >> ai;
    as[i] = (ai == '?') ? -1 : ai - 'a';
  }

  for (int i = 0; i < en; i++) {
    int si, ti;
    cin >> si >> ti;

    nbrs[si].push_back(ti);
    if (as[ti] >= 0) used[si][as[ti]] = true;

    nbrs[ti].push_back(si);
    if (as[si] >= 0) used[ti][as[si]] = true;
  }

  for (int i = 0; i < vn; i++) {
    if (as[i] < 0) {
      for (int j = 0; j < 26; j++)
	if (! used[i][j]) {
	  as[i] = j;
	  break;
	}

      vi &nbri = nbrs[i];
      for (vi::iterator vit = nbri.begin(); vit != nbri.end(); vit++)
	used[*vit][as[i]] = true;

    }

    putchar(as[i] + 'a');
  }
  putchar('\n');

  return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 10864
final_rank: 16

code_snippet: #include<bits/stdc++.h>
using namespace std;

int v,e;
char a[100100];
vector<int> g[100100];

int main(){
  cin >> v >> e;
  for(int i=0;i<v;i++)cin >> a[i];
  for(int i=0;i<e;i++){
    int s,t;
    cin >> s >> t;
    g[s].push_back(t); g[t].push_back(s);
  }

  for(int i=0;i<v;i++){
    if(a[i] == '?'){
      bool use[30] = {};
      for(int j=0;j<(int)g[i].size();j++){
	int u = g[i][j];
	if(a[u] != '?')use[a[u]-'a'] = true;
      }
      
      for(int j=0;j<26;j++){
	if(!use[j]){
	  cout << (a[i] = (char)('a' + j));
	  break;
	}
      }
    }else cout << a[i];
  }
  cout << endl;
}
accuracy: 1
time_ms: 130
memory_kb: 8080
final_rank: 15

code_snippet: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<29
#define EPS 1e-9
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

const int MAX_V = (int)1e5 + 5;
int V, E;
vector<int> G[MAX_V];
vector<char> v;
bool used[26];

int main()
{
//	cut here before submit 
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	v.clear();
	rep (i, MAX_V ) G[i].clear();
	ios_base::sync_with_stdio(0);
	cin >> V >> E;
 	v.resize (V, 0 );
	rep (i, V ) cin >> v[i];
	rep (i, E ){
		int s, t;
		cin >> s >> t;
		G[s].push_back (t );
		G[t].push_back (s );
	} // end rep

	rep (i, V ){
		if (v[i] == '?' ){
			memset (used, false, sizeof (used ) );
			rep (j, G[i].size() ){
				int u = G[i][j];
				if (v[u] != '?' ) used[(int)(v[u] - 'a')] |= true;
			} // end rep
			rep (j, 26 ){
				if (!used[j] ){
					v[i] = (char)(j+'a');
					break;
				} // end if
			} // end rep
		} // end if
	} // end rep

	rep (i, V ) cout << v[i];
	cout << endl;
#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif			
	return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 8112
final_rank: 3

code_snippet: #include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < int(Y);++(X))
#define rrep(X,Y) for (int (X) = int(Y-1);(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int v,e;

int main(){
  int i,j,k;
  cin>>v>>e;
  vector<char> cs(v);
  vector<int> edges[v];
  rep(i,v)
    cin>>cs[i];
  int te,mp;
  rep(i,e){
    cin>>te>>mp;
    edges[te].pb(mp);
    edges[mp].pb(te);
  }
  rep(i,v){
    if(cs[i]!='?')continue;
    vector<int> memo(256,0);
    rep(j,edges[i].size())
      memo[cs[edges[i][j]]]=1;
    char cc;
    for(cc='a';cc<='z';cc++)
      if(!memo[cc])break;
    cs[i]=cc;
  }
  rep(i,v)
    cout<<cs[i];cout<<endl;
  return 0;
}
accuracy: 1
time_ms: 140
memory_kb: 7868
final_rank: 17

code_snippet: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

bool flg[100005][27];
vector<int> G[100005];
	
int V,E;
char A[100005]={0};

int main()
{
	scanf("%d%d\n",&V,&E);
	for(int i=0;i<V;i++)
	{
		scanf("%c%*c",&A[i]);
	}
	for(int i=0;i<E;i++)
	{
		int s,t;
		scanf("%d%d",&s,&t);
		G[s].push_back(t);
		G[t].push_back(s);
	}
	for(int i=0;i<V;i++)
	{
		if(A[i]!='?')flg[i][A[i]-'a']=1;
	}
	for(int i=0;i<V;i++)
	{
		if(A[i]=='?')
		{
			for(char x='a';x<='z';x++)
			{
				int j;
				for(j=0;j<G[i].size();j++)
				{
					if(flg[G[i][j]][x-'a'])break;
				}
				if(j==G[i].size())
				{
					A[i]=x;
					flg[i][x-'a']=1;
					break;
				}
			}
		}
	}
	puts(A);
}
accuracy: 1
time_ms: 60
memory_kb: 10656
final_rank: 4

code_snippet: #include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int v,e;
vector<int> edge[100000];
string a;
set<char> able[100000];

int main(){
	cin>>v>>e;
	rep(i,v){
		rep(j,26)able[i].insert('a'+j);
	}
	rep(i,v){
		char c;
		cin>>c;
		a+=c;
	}
	rep(i,e){
		int s,t;
		cin>>s>>t;
		edge[s].push_back(t);
		edge[t].push_back(s);
	}
	rep(i,v){
		if(a[i]=='?')continue;
		rep(j,edge[i].size()){
			able[edge[i][j]].erase(a[i]);
		}
	}
	rep(i,v){
		if(a[i]!='?')continue;
		char c=*able[i].begin();
		a[i]=c;
		rep(j,edge[i].size()){
			able[edge[i][j]].erase(c);
		}
	}
	cout<<a<<endl;
	return 0;
}
accuracy: 1
time_ms: 460
memory_kb: 134660
final_rank: 20

code_snippet: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

using namespace std;

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
template <typename T> void print_container(ostream& os, const T& c) { const char* _s = " "; if (!c.empty()) { __typeof__(c.begin()) last = --c.end(); foreach (it, c) { os << *it; if (it != last) os << _s; } } }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& c) { print_container(os, c); return os; }
template <typename T> ostream& operator<<(ostream& os, const set<T>& c) { print_container(os, c); return os; }
template <typename T> ostream& operator<<(ostream& os, const multiset<T>& c) { print_container(os, c); return os; }
template <typename T> ostream& operator<<(ostream& os, const deque<T>& c) { print_container(os, c); return os; }
template <typename T, typename U> ostream& operator<<(ostream& os, const map<T, U>& c) { print_container(os, c); return os; }
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }

template <typename T> void print(T a, int n, const string& split = " ") { for (int i = 0; i < n; i++) { cout << a[i]; if (i + 1 != n) cout << split; } cout << endl; }
template <typename T> void print2d(T a, int w, int h, int width = -1, int br = 0) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }
template <typename T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
#define dump(v) (cerr << #v << ": " << v << endl)

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define erep(i, n) for (int i = 0; i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(a, x) memset(a, x, sizeof(a))
#define sz(a) ((int)(a).size())
#define mp(a, b) make_pair(a, b)
#define ten(n) ((long long)(1e##n))

template <typename T, typename U> void upmin(T& a, const U& b) { a = min<T>(a, b); }
template <typename T, typename U> void upmax(T& a, const U& b) { a = max<T>(a, b); }
template <typename T> void uniq(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
    fast_io();

    int n, m;
    cin >> n >> m;
    string maru(n, '@');
    rep(i, n)
        cin >> maru[i];
    vector<vector<int>> g(n);
    rep(i, m)
    {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    rep(i, n)
    {
        if (maru[i] != '?')
            continue;

        bool ng[26] = {};
        for (int j : g[i])
            if (maru[j] != '?')
                ng[maru[j] - 'a'] = true;

        rep(k, 26)
        {
            if (!ng[k])
            {
                maru[i] = 'a' + k;
                break;
            }
        }
    }
    cout << maru << endl;
}
accuracy: 1
time_ms: 50
memory_kb: 7860
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef pair<int, int> pii;

int V, E;
char ans[100010];
vector< vector<int> > edges;

set<char> cand[100010];

void solve() {
	for_(i,0,V) {
		cand[i].clear();
		if (ans[i] != '?') continue;
		for_(j,0,26) {
			cand[i].insert('a' + j);
		}
	}
	
	for_(i,0,V) {
		if (ans[i] != '?') {
			int e_size = size_of(edges[i]);
			for_(j,0,e_size) {
				int u = edges[i][j];
				cand[u].erase(ans[i]);
			}
		}
	}
	
	for_(i,0,V) {
		if (ans[i] == '?') {
			char c = *cand[i].begin();
			ans[i] = c;
			int e_size = size_of(edges[i]);
			for_(j,0,e_size) {
				int u = edges[i][j];
				cand[u].erase(c);
			}
		}
		
		cout << ans[i];
	}
	cout << endl;
}

int main() {
	cin >> V >> E;
	for_(i,0,V) {
		char c; cin >> c;
		ans[i] = c;
	}
	edges.assign(V, vector<int>());
	for_(i,0,E) {
		int s, t; cin >> s >> t;
		edges[s].push_back(t);
		edges[t].push_back(s);
	}
	solve();
	return 0;
}
accuracy: 1
time_ms: 370
memory_kb: 134260
final_rank: 19

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
const int INF=1<<30;
using namespace std;
typedef pair<int,int> pr;
typedef vector<int> vi;
char word[100001];
vi edge[100001];
int V,E,a,b;
void search(int num){
	if(num==V)
	return ;
	if(word[num]=='?'){
	bool used[27]={};
	REP(i,edge[num].size())
	if(word[edge[num][i]] !='?')
	used[word[edge[num][i]]-'a']=true;
	REP(i,26)
	if(!used[i]){
		word[num]=i+'a';
		break;
	}
	}
	cout << word[num];
	search(num+1);
	return ;
}
int main() {
	cin >> V >> E;
	REP(i,V)
	cin >> word[i];
	REP(j,E){
	cin >> a >> b;
	edge[a].push_back(b);
	edge[b].push_back(a);
	}
	search(0);
	cout << endl;
	// your code goes here
	return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 8076
final_rank: 14