Submission #345429

# Submission time Handle Problem Language Result Execution time Memory
345429 2021-01-07T09:57:16 Z Iwanttobreakfree Miners (IOI07_miners) C++
Compilation error
0 ms 0 KB
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
int ship,production,cont1,cont2;
using namespace std;
string mine1;
string mine2;
int main(){
	cin>>ship{
	char food[ship];
	for(int a=0;a<ship;a++){
		cin>>food[a];
	}
	cont1=1;
	cont2=0;
	mine1[0]=food[0];
	production=1;
	
	for(int b=1;b<ship;b++){	
		if(cont1==1&&cont2==0){
			if(food[b]!=mine1[cont1-1]) mine1[cont1]=food[b],cont1++,production+=2;
			else mine2[cont2]=food[b],cont2++,production++;
		}
		else if(cont1>=2&&cont2==0){
			if(food[b]!=mine1[cont1-1]&&mine1[cont1-1]!=mine1[cont1-2]&&food[b]!=mine1[cont1-2]) mine1[cont1]=food[b],cont1++,production+=3;
			else mine2[cont2]=food[b],cont2++,production++;
		}
		else if(cont1==1&&cont2==1){
			if     (food[b]!=mine1[cont1-1]) mine1[cont1]=food[b],cont1++,production+=2;
			else if(food[b]!=mine2[cont2-1]) mine2[cont2]=food[b],cont2++,production+=2;
			else mine1[cont1]=food[b],cont1++,production++;
		}
		else if(cont1>=2&&cont2==1){
			if     (food[b]!=mine1[cont1-1]&&food[b]!=mine1[cont1-2]&&mine1[cont1-1]!=mine1[cont1-2])mine1[cont1]=food[b],cont1++,production+=3;
			else if(food[b]!=mine2[cont2-1])mine2[cont2]=food[b],cont2++,production+=2;
			else if(food[b]!=mine1[cont1-1]||food[b]!=mine1[cont1-2]||mine1[cont1-1]!=mine1[cont1-2])mine1[cont1]=food[b],cont1++,production+=2;
			else mine1[cont1]=food[b],cont1++,production++;
		}
		else{
		if     (food[b]!=mine1[cont1-1]&&food[b]!=mine1[cont1-2]&&mine1[cont1-1]!=mine1[cont1-2])mine1[cont1]=food[b],cont1++,production+=3;
		else if(food[b]!=mine2[cont2-1]&&food[b]!=mine2[cont2-2]&&mine2[cont2-1]!=mine2[cont2-2])mine2[cont2]=food[b],cont2++,production+=3;
		else if(food[b]!=mine1[cont1-1]||food[b]!=mine1[cont1-2]||mine1[cont1-1]!=mine1[cont1-2])mine1[cont1]=food[b],cont1++,production+=2;
		else if(food[b]!=mine2[cont2-1]||food[b]!=mine2[cont2-2]||mine2[cont2-1]!=mine2[cont2-2])mine2[cont2]=food[b],cont2++,production+=2;
		else mine1[cont1]=food[b],cont1++,production++;
	}
	}
	cout<<production<<endl;	
}
	return 0;
}

Compilation message

miners.cpp: In function 'int main()':
miners.cpp:11:11: error: expected ';' before '{' token
   11 |  cin>>ship{
      |           ^
      |           ;