CSES - Datatähti 2025 alku - Results
Submission details
Task:Robotti
Sender:menta
Submission time:2024-10-29 22:03:57 +0200
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:8:8: error: expected ';' before 'char'
    8 | an=an+1
      |        ^
      |        ;
    9 | char jee[an];
      | ~~~~    
input/code.cpp:11:21: error: 'jee' was not declared in this scope
   11 |         scanf("%c",&jee[i]);
      |                     ^~~
input/code.cpp:21:14: error: 'jee' was not declared in this scope
   21 |         if ((jee[r-vas])=='*'&&yl==0){
      |              ^~~
input/code.cpp:29:14: error: 'jee' was not declared in this scope
   29 |         if ((jee[r+oik])=='*'&&kl==0){
      |              ^~~
input/code.cpp:39:25: error: 'jee' was not declared in this scope
   39 |                         jee[r]='.';
      |                         ^~~
input/code.cpp:52:25: error: 'jee' was not declared in this scope
   52 |                         jee[r]='.';
      |                         ^~~

Code

#include <bits/stdc++.h>
using namespace std;
int an,r,i,j,a,c,vask,oikk,vas,oik,ko,yl,kl,rl;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>an;
an=an+1
char jee[an];
for(i=0;i<=an;i=i+1){
	scanf("%c",&jee[i]);
	if(jee[i]=='R'){
		r=i;
	}
	}
while(true){
	if ((vas-r)>0&&yl==0){
		vask=an+1;
		yl=1;
	}
	if ((jee[r-vas])=='*'&&yl==0){
                vask=vas;
		yl=1;
        }
	if ((r+oik)>an&&kl==0){
                oikk=an+1;
		kl=1;
        }
	if ((jee[r+oik])=='*'&&kl==0){
                oikk=oik;
		kl=1;
        }
	if (kl==0){oik=oik+1;}
        if (yl==0){vas=vas+1;}
	if (yl!=0&&kl!=0){
		if(vask>oikk){
			//cout<<vas<<"\n"<<oik<<"\n"<<"o"<<"\n";
        		r=r+oikk;
                	jee[r]='.';
                	c=c+1;
                	a=a+oikk;
                	vask=0;
                	oikk=0;
                	oik=1;
                	vas=1;
                	yl=0;
                	kl=0;
                	}
        	else if(vask<oikk){
                	//cout<<vas<<"\n"<<oik<<"\n"<<"v"<<"\n";
                	r=r-vask;
                	jee[r]='.';
                	c=c+1;
                	a=a+vask;
                	vask=0;
                	oikk=0;
                	oik=1;
                	vas=1;
                	yl=0;
                	kl=0;
        	}
		else if(vask==oikk) {
                	//cout<<vas<<"\n"<<oik<<"\n"<<"lopuu"<<"\n";
                	break;
        		}
	}
}
cout<<a<<" "<<c;
}