Submission #319925

# Submission time Handle Problem Language Result Execution time Memory
319925 2020-11-06T20:03:00 Z ignaciocanta Tavan (COCI16_tavan) C++14
40 / 80
1 ms 512 KB
#include <bits/stdc++.h>
 
using namespace std;
 
using tint = long long;
using ld = long double;
 
#define forsn(i, s, n) for(int i = s; i < int(n); i++)
#define forn(i, n) forsn(i, 0, n)
 
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend() 
#define sz(x) (int)(x).size()
 
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
 
#define DBG(x) cerr << #x << " = " << x << endl;
 
const int MOD = 1e9+7;
const int MX = 1e5+5;
const tint INF = 2e18;
const int inf = 2e9;
const ld PI = acos(ld(-1)); 
 
void NACHO(string name = "moop"){
    ios_base::sync_with_stdio(0); cin.tie(0);
   // freopen((name+".in").c_str(), "r", stdin);
   // freopen((name+".in").c_str(), "w", stdout);
}
 
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

bool valid(int x, int y, int n, int m){
	return (0<=x && x<n && 0<=y && y<m);
}

vector<string> convert(int n, int k){
	vector<string> ret ;
	while(n > 0){
		ret.pb(to_string(n%k));
		n/=k;
	}
	reverse(all(ret));
	return ret;
}

int main(){
	NACHO();
	int n, m, k, x; cin >> n >> m >> k >> x;
	string s; cin >> s;
	vector<string> baseK = convert(x-1, k);
	vector<char> ans (m);
	forn(i, m){
		string S; cin >> S;
		sort(all(S));
		ans[i] = S[stoi(baseK[i])];
	}
	int c = 0;
	forn(i, n){
		if(s[i] == '#') cout << ans[c++];
		else cout << s[i];
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 396 KB Output is correct
3 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 268 KB Output is correct
7 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)