Algorithm


problem link- https://www.spoj.com/problems/AVION1/

AVION1 - AVION

no tags 

 

Mirko and Slavko are USKOK agents tracking the movements of an unnamed corrupt government official. Anonymous sources have tipped them about his upcoming escape attempt. They now know he plans to use his diplomatic liaisons to try and hitch a ride on a CIA blimp leaving from Severin na Kupi blimp port.

It’s common knowledge that all CIA blimps have the string “FBI” somewhere in their registration codes. They obtained a list of all blimps scheduled for the designated day. There are exactly 5 blimps on the list. Write a program that will point out all CIA blimps.

Input

There are exactly 5 rows of input, each row representing one blimp registration code from the list. A registration code is a sequence of at most 10 uppercase letters of the English alphabet, digits ‘0’ to ‘9’, or dashes ‘-’.

Output

The first and only line of output must contain a space separated list of integers, sorted in increasing order, indicating the corresponding input rows containing registrations of CIA blimps. If there are no CIA blimps, output the string “HE GOT AWAY!”

Sample

Input:
N-FBI1
9A-USKOK
I-NTERPOL
G-MI6
RF-KGB1

Output:
1
Input:
N321-CIA
F3-B12I
F-BI-12
OVO-JE-CIA
KRIJUMCAR1

Output:
HE GOT AWAY!

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <map>
#include <list>

using namespace std;

int main(){
		string s[5];
		vector<int> count;
		string f="FBI";
		for(int i=0;i<5;i++){
			cin>>s[i];
			if(s[i].find(f)!=string::npos)
				count.push_back(i+1);
		}
		if(count.size()==0){
			printf("HE GOT AWAY!\n");
		}
		else{
			for(int i=0;i<count.size();i++){
				printf("%d",count[i]);
				if(i!=(count.size()-1)){
					printf(" ");
				}
			}
		}
		printf("\n");
	return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
N-FBI1
9A-USKOK
I-NTERPOL
G-MI6
RF-KGB1

Output

x
+
cmd
1
Advertisements

Demonstration


SPOJ Solution-AVION-Solution in C, C++, Java, Python

Previous
SPOJ Solution - Test Life, the Universe, and Everything - Solution in C, C++, Java, Python