CSES - Datatähti 2021 alku - Results
Submission details
Task:2021-luvut
Sender:Epe
Submission time:2020-10-05 17:52:04 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:35:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int p = 0; p < vec.size(); p++){
                  ~~^~~~~~~~~~~~
input/code.cpp:38:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(p == vec.size()-1){
        ~~^~~~~~~~~~~~~~~
input/code.cpp:47:2: error: 'stringsteam' was not declared in this scope
  stringsteam ss;
  ^~~~~~~~~~~
input/code.cpp:49:3: error: 'ss' was not declared in this scope
   ss << vec[p];
   ^~
input/code.cpp:51:10: error: 'ss' was not declared in this scope
  cout << ss.rdbuf() << endl;
          ^~

Code

#include <bits/stdc++.h>
#include <cstring>

using namespace std;


int main(){
	int n;
	cin >> n;

	vector<int> vec = {1, 2, 0, 2};
	n--;
	while(n){
		bool a = 0,b= 0,c= 0,d= 0;
		for(int p = vec.size()-1; p >= 0; p--){
			int u = vec[p];
			if(u == 2){
				if(!a){
					a = true;
				} else if (b){
					c = true;
				}
			} else if (a && u == 0){
				b = true;
			} else if (c && u == 1){
				d = true;
			}
		}
		if(a && b && c && d){
			n--;
			if(n <= 0){
				break;
			}
		}
		for(int p = 0; p < vec.size(); p++){
			if(vec[p] == 9){
				vec[p] = 0;
				if(p == vec.size()-1){
					vec.push_back(1);
				}
			} else {
				vec[p]++;
				break;
			}
		}
	}
	stringsteam ss;
	for(int p = vec.size()-1; p >= 0; p--){
		ss << vec[p];
	}
	cout << ss.rdbuf() << endl;
}