CSES - Datatähti 2024 alku - Results
Submission details
Task:Monistus
Sender:qanpi
Submission time:2023-11-08 23:17:57 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'std::vector<char> solve(std::vector<char>)':
input/code.cpp:43:30: warning: variable 'v' set but not used [-Wunused-but-set-variable]
   43 |                         auto v = before.insert(before.end(), expanded.begin(), expanded.end());
      |                              ^
input/code.cpp: In function 'int main()':
input/code.cpp:60:34: error: could not convert '0' from 'int' to 'std::vector<char>'
   60 |         vector<char> ans = solve(0);
      |                                  ^
      |                                  |
      |                                  int

Code

#include<iostream>
#include<bits/stdc++.h>
#include<string> 
#include<map>
#include <unordered_map>
using namespace std;

typedef long long ll;
 
constexpr ll M = 1000000007;
constexpr ll P = (1 << 18);
constexpr int INF = 1e9;

//unordered_map<string, string> m;

char arr[101010];

vector<char> solve(vector<char> s) {
	for (int i=0; i<(int)s.size(); i++) {
		char ch = s[i];
		int digit = ch - '0'; 

		if (digit > 0 && digit <= 9) {
			//string before = s.substr(0, i); 
			//string expanded = s.substr(i+1, digit); 
			//string after = s.substr(i+1); 
			vector<char> before(s.begin(), s.begin()+i);
			vector<char> expanded(&s[i+1], &s[i+1]+digit);
			vector<char> after(&s[i+1], &s.back()); 

			for (auto a : before) cout << a << " ";
			cout << endl;

			for (auto a : expanded) cout << a << " ";
			cout << endl;

			for (auto a : after) cout << a << " ";
			cout << endl;
//			cout << i << " " << digit << " " << before << " " << expanded << " " << after << endl;
//			cout << "key:" << digit << expanded <<endl;
			
			//store expanded + after in a hashmap
			auto v = before.insert(before.end(), expanded.begin(), expanded.end());

			//return solve(**v); 
			return after;
			//m[digit + expanded] =;
		}
	}

	return s;
}

int main() {
	string input; 
	cin >> input;

	//vector<char> arr(input.begin(), input.end());

	vector<char> ans = solve(0);

	for (auto ch : ans) cout << ch << " ";
	cout << endl;

}