NC24431. Clarifications
描述
输入描述
The input contains multiple lines.
The first line contains two integers n, q(1 <= n <= 10000, 1 <= q <= 100), indicates the number of requests and the number of stupid questions.
Each of the next q lines contains a distinct stupid question.
Then each of the next n lines contains a request for clarification.
It's guaranteed that the all given strings will only contain Latin letters and spaces, and each line ends with a period or a question mark. The length of each of them will not exceed 100.
输出描述
Output exactly n lines. The i-th line represents the answer to the i-th request of clarifications.
示例1
输入:
10 2 Why I got WA on problem A? How to solve problem C? The problems are really good. Why I got WA on problem A? Why I got CE? Why I got CE? How to solve problem C? Why I got CE? Why I got CE? Why I got CE? The constraint of E is correct? Why I got CE?
输出:
No Response. 42. Read the problem statement carefully. Read the problem statement carefully. 42. Read the problem statement carefully. Read the problem statement carefully. Read the problem statement carefully. Read the problem statement carefully. Juries are investigating. Thanks.
Python(2.7.3) 解法, 执行用时: 34ms, 内存消耗: 4064K, 提交时间: 2019-04-14 13:00:16
l = raw_input().strip().split() n = int(l[0]) q = int(l[1]) stp = [raw_input().strip() for i in range(q)] count = {} for i in range(n): line = raw_input().strip() if line.endswith("."): print "No Response." elif line in stp: print "42." else: if line not in count: print "Read the problem statement carefully." count[line] = 1 else: if count[line] < 5: print "Read the problem statement carefully." count[line] += 1 else: print "Juries are investigating. Thanks."
Go(1.9.1) 解法, 执行用时: 44ms, 内存消耗: 2656K, 提交时间: 2019-04-14 21:32:24
package main import ( "bufio" "fmt" "os" "strings" ) func main(){ var ( n int m int ) fmt.Scanf("%d %d",&n,&m) s1 := make(map[string] int) input := bufio.NewScanner(os.Stdin) for i:=0;i<m;i++{ input.Scan() s1[input.Text()]=-1 } for j := 0; j < n; j++ { input.Scan() if strings.HasSuffix(input.Text(),".") { fmt.Println("No Response.") }else if s1[input.Text()]==-1{ fmt.Println("42.") }else if s1[input.Text()]<5 { s1[input.Text()]++ fmt.Println("Read the problem statement carefully.") }else { fmt.Println("Juries are investigating. Thanks.") } } }
C++14(g++5.4) 解法, 执行用时: 37ms, 内存消耗: 1636K, 提交时间: 2019-04-14 12:40:29
#include<bits/stdc++.h> using namespace std; map<string,int>mp; set<string>s; int main() { int n,m; cin>>n>>m; getchar(); while(m--) { string ss; getline(cin,ss); s.insert(ss); } while(n--) { string ss; getline(cin,ss); if(s.count(ss)) { cout<<"42."<<endl; continue; } int l=ss.size(); if(ss[l-1]=='.') { cout<<"No Response."<<endl; } else { // cout<<mp[ss]<<"?????"<<endl; if(mp[ss]>=5) cout<<"Juries are investigating. Thanks."<<endl; else cout<<"Read the problem statement carefully."<<endl; } mp[ss]++; } }
C++11(clang++ 3.9) 解法, 执行用时: 69ms, 内存消耗: 2388K, 提交时间: 2019-04-18 14:05:29
#include <bits/stdc++.h> using namespace std; map<string,int>p; map<string,int>v; int main() { int n,q; string str,str1; cin>>n>>q; getchar(); while(q--) { getline(cin,str1);v[str1]=1; } while(n--) { getline(cin,str); if(str[str.size()-1]=='.') printf("No Response.\n"); else if(v[str]) printf("42.\n"); else{ if(p[str]<5) printf("Read the problem statement carefully.\n"); else printf("Juries are investigating. Thanks.\n"); } ++p[str]; } }