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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:10:13: error: expected ';' before 'for'
   10 | scanf("%*c")
      |             ^
      |             ;
   11 | for(i=0;i<an;i=i+1){
      | ~~~          
input/code.cpp:11:10: warning: statement has no effect [-Wunused-value]
   11 | for(i=0;i<an;i=i+1){
      |         ~^~~
input/code.cpp:11:19: error: expected ';' before ')' token
   11 | for(i=0;i<an;i=i+1){
      |                   ^
      |                   ;
input/code.cpp:10:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | scanf("%*c")
      | ~~~~~^~~~~~~

Code

#include <bits/stdc++.h>
using namespace std;
char har;
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;
char jee[an];
scanf("%*c")
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;
}