|
|||
DependenciesAmazon Web Services (AWS) CloudFormation is a service that helps you model and set up your AWS resources so that you can spend less time managing those resources and more time focusing on your applications that run in AWS. You create a template that describes all the AWS resources that you want, and CloudFormation takes care of provisioning and configuring those resources for you. In a CloudFormation template, you specify the logical names of resources, together with their properties, including the dependent resources. The logical name (or logical ID) must be alphanumeric and unique within the template. The logical name is used to reference to the resource in other parts of the template.
In the following CloudFormation template, such logical names are AWSTemplateFormatVersion: 2010-09-09 Description: A sample template Resources: MyEC2Instance: Type: 'AWS::EC2::Instance' Properties: ImageId: ami-0ff8a91507f77f867 InstanceType: t2.micro KeyName: testkey BlockDeviceMappings: - DeviceName: /dev/sdm Ebs: VolumeType: io1 Iops: 200 DeleteOnTermination: false VolumeSize: 20 MyEIP: Type: 'AWS::EC2::EIP' Properties: InstanceId: !Ref MyEC2Instance Write a program that reads logical names of resources given in an AWS CloudFormation template from the standard input. For each logical name, you will be given all the other names of resources that are required to exist for the resource to be created. Your program has to determine whether a given sequence of resources can or cannot be created in the specified order, and if not, the program also has to give the logical names of all resources in the sequence that cannot be created. Input Specification
The first line of the input contains two integers R and S, representing the
number of resources and the number of sequences, respectively
(1 ≤ R ≤ 100,
1 ≤ S ≤ 100). Each of the following R lines
describes a resource and its dependencies (in no particular order). Each resource is
represented by an identifier, which is a string of at most 20 alphanumeric characters. The
first resource in each line is followed by a colon (“ Output SpecificationFor each sequence in the input, print one line to the output.
If there are at least two resources in the sequence that cannot be created in the given order
(“problematic” resources), then print
“
If there is only one problematic resource, print the message
“
If all the resources can be created in the order presented in the sequence, then print
“ Sample Input 1
Output for Sample Input 1
Sample Input 2
Output for Sample Input 2
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |