CSES - Datatähti 2024 alku - Results
Submission details
Task:Monistus
Sender:maweiyin24562
Submission time:2023-11-03 17:24:34 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp:2:9: fatal error: windows.h: No such file or directory
    2 | #include<windows.h>
      |         ^~~~~~~~~~~
compilation terminated.

Code

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

bool isDigit(char c){
	return c>='0'&&c<='9';
}

bool isClear(string s){
	for(int i=0;i<s.size();i++){
		if(isDigit(s[i]))return false;
	}
	return true;
}

bool vst=false;

string dfs(string s){
	if(s.size()<=1){
		return s;
	}
	string result="";
	for(int i=0;i<s.size();i++){//O(n)
		if(isDigit(s[i])&&!vst){
			vst=true;
			int m=s[i]-'0';
			if(i+m>=s.size())
				result+=s[i];
			else
				result+=dfs(s.substr(i+1,m));
		}
		else{
			result+=s[i];
		}
	}
	return result;
}

string dfs2(string s){
	if(s.size()<=1){
		return s;
	}
	string result="";
	for(int i=0;i<s.size();i++){//O(n)
		if(isDigit(s[i])){
			int m=s[i]-'0';
			if(i+m>=s.size())
				result+=s[i];
			else
				result+=dfs(s.substr(i+1,m));
		}
		else{
			result+=s[i];
		}
	}
	return result;
}

int main(){
	cin>>str;
	
//	string str2=str;
	while(!isClear(str)){//O(n)
		vst=false;
		str=dfs(str);
	}
	
	cout<<str<<endl;
	
//	while(!isClear(str2)){
//		str2=dfs2(str2);
//	}
//	
//	cout<<str2<<endl;
	
	return 0;
}