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 
****************************************************************/ 



你可能感兴趣的:(UPC_Shandong muti-university Contest Problem I——The war of 3Q)