UPC_Shandong muti-university Contest Problem I——The war of 3Q

比赛链接:点击打开链接

Problem I: The war of 3Q.

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 50  Solved: 10
[ Submit][ Status][ Web Board]

Description

One day,China's Internet firm Tencent said it is shutting down its popular instant messaging service QQ on computers installed with anti-virus software run by the company's rival Qihoo360, as a war between the two software giants escalated over the course of the past several months.

Input

INPUT:

This problem has two parts.

Part #1:

The first line of Part #1 is an integer N(N<=100), which stands for the number of operations:

Then N lines follow, each line as an operation.

The operations should be described as :

Create File_name Ext_name

If there is a file called File_name,then output “File already exist!” and ignore this operation, else create that file.

Delete File_name

If there is a file called File_name,then remove it;else output ”No such file!” and ignore this operation.

QQ File_name

If the file called File_name does not exist, output”No such file!”; else if the Ext_name is”exe” then output ”QQ has not collected your private information!”, otherwise output ” QQ has collected your private information!”.

Part #2:

There is a list of softwares by Qihoo 360.

360SAFE

360BROWSER

QQGUARD

360SD

360DESKTOP

360YASUO

360WD

360SAFEBOX

The following line is an integer M(M<=100), which stands for the number of operations:

Then M lines follow, each line as an operation.

The operations should be described as:

Install Software_name

If the software called Software_name is installed, output “The software is already installed!” and ignore the operation; else install it.

Uninstall Software_name

If the software called Software_name does not exist, output “The software is not found!” and ignore the operation; else uninstall it.

360

If all the softwares in the list are installed in your computer, output “Your computer is secure!” else output “Your computer is not secure!”

Output

The output is specified before.

Sample Input

5Create qq exeCreate search datQQ searchDelete qqmusicCreate qq exe3Install 360SAFEInstall 360SAFE360

Sample Output

QQ has collected your private information!No such file!File already exist!The software is already installed!Your computer is not secure!

模拟题,没什么好说的,注意手一定不要残,还有就是不要怕麻烦,思路顺了很EASY。

#include <iostream> 
#include <cmath> 
#include <cstring> 
#include <map> 
#include <string> 
using namespace std; 
  
class file 
{ 
    public: 
        string mainfile; 
        string ext; 
}; 
  
file ls[100]; 
  
  
int main() 
{ 
    int testcase1,testcase2; 
    cin>>testcase1; 
    { 
        string op,tarfile,ext; 
        map<string,int> filelist; 
        map<string,int> softwarelist; 
        map<string,int>::iterator itp; 
          
        int ucount=0; 
        while(testcase1--) 
        { 
            map<string,int>::iterator it; 
            cin>>op>>tarfile; 
            if(op[0]=='C') 
            { 
                cin>>ext; 
                ls[ucount].mainfile=tarfile; 
                ls[ucount].ext=ext; 
                ucount++; 
            } 
  
            if(op[0]=='C') 
            { 
                it=filelist.find(tarfile); 
                if(it!=filelist.end()) 
                { 
                    cout<<"File already exist!"<<endl; 
                    continue; 
                } 
                else
                    filelist[tarfile]++; 
            } 
              
            else if(op[0]=='D') 
            { 
                it=filelist.find(tarfile); 
                if(it==filelist.end()) 
                { 
                    cout<<"No such file!"<<endl; 
                    continue; 
                } 
                else
                { 
                    filelist.erase(it); 
                } 
            } 
              
            else if(op[0]=='Q') 
            { 
                it=filelist.find(tarfile); 
                if(it==filelist.end()) 
                { 
                    cout<<"No such file!"<<endl; 
                } 
                else
                { 
                    for(int i=0;i<=ucount;i++) 
                    { 
                        if(ls[i].mainfile==tarfile) 
                        { 
                            if(ls[i].ext=="exe") 
                            { 
                                cout<<"QQ has not collected your private information!"<<endl; 
                                break; 
                            } 
                            else
                            { 
                                cout<<"QQ has collected your private information!"<<endl; 
                                break; 
                            } 
                        } 
                    } 
                } 
            } 
              
        } 
        string soft; 
        cin>>testcase2; 
        while(testcase2--) 
        { 
            map<string,int>::iterator it; 
            cin>>op; 
            if(op!="360") 
                cin>>soft; 
            if(op[0]=='I') 
            { 
                it=softwarelist.find(soft); 
                if(it!=softwarelist.end()) 
                { 
                    cout<<"The software is already installed!"<<endl; 
                } 
                else
                    softwarelist[soft]++; 
                      
            } 
            else if(op[0]=='U') 
            { 
                it=softwarelist.find(soft); 
                if(it==softwarelist.end()) 
                { 
                    cout<<"The software is not found!"<<endl; 
                    continue; 
                } 
                else
                    softwarelist.erase(it); 
            } 
              
            else if(op[0]=='3') 
            { 
                int soft=0; 
                for(itp=softwarelist.begin();itp!=softwarelist.end();itp++) 
                { 
                    if((*itp).first=="360SAFE"||(*itp).first=="360BROWSER"||(*itp).first=="QQGUARD"||(*itp).first=="360SD"||(*itp).first=="360DESKTOP"||(*itp).first=="360YASUO"||(*itp).first=="360WD"||(*itp).first=="360SAFEBOX") 
                    { 
                        soft++; 
                        continue; 
                    } 
                          
                } 
                if(soft==8) 
                { 
                    cout<<"Your computer is secure!"<<endl; 
                } 
                else
                { 
                    cout<<"Your computer is not secure!"<<endl; 
                } 
                  
                  
            } 
              
              
        } 
          
          
    } 
    return 0; 
} 
  
/************************************************************** 
    Problem: 2136 
    User: warm_nova 
    Language: C++ 
    Result: Accepted 
    Time:20 ms 
    Memory:1276 kb 
****************************************************************/ 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值