QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#487022 | #5347. Trending Topic | PetroTarnavskyi# | Compile Error | / | / | C++20 | 1.6kb | 2024-07-22 15:21:37 | 2024-07-22 15:21:37 |
Judging History
answer
//#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
string str;
int day = 0;
vector<vector<string>> vec = {{}};
VI queries;
while (cin >> str)
{
if (str.empty())
continue;
if (str == "<text>")
{
vec.PB({});
queries.PB(-1);
continue;
}
if (str == "</text>")
{
day++;
continue;
}
if (str == "<top")
{
cin >> queries[day];
cin >> str;
assert(str == "/>");
continue;
}
if (SZ(str) >= 4)
vec[day].PB(str);
}
map<string, int> cnt;
set<pair<int, string>> se;
auto updCnt = [&](const string& s, int d)
{
se.erase({-cnt[s], s});
cnt[s] += d;
if (cnt[s] != 0)
se.insert({-cnt[s], s});
};
FOR(i, 0, SZ(vec))
{
for (const string& s : vec[i])
{
updCnt(s, 1);
}
if (i >= 7)
{
for (const string& s : vec[i - 7])
{
updCnt(s, -1);
}
}
if (queries[i] != -1)
{
cout << "<top " << queries[i] << ">\n";
int j = 0, lastC = 0;
for (const auto& [c, s] : se)
{
if (j < queries[i] || c == lastC)
cout << s << " " << -c << "\n";
else
break;
if (j == queries[i] - 1)
lastC = c;
j++;
}
cout << "</top>\n";
}
}
return 0;
}
Details
answer.code:15:9: error: ‘vector’ does not name a type 15 | typedef vector<int> VI; | ^~~~~~ answer.code:16:9: error: ‘pair’ does not name a type 16 | typedef pair<int, int> PII; | ^~~~ answer.code: In function ‘int main()’: answer.code:21:9: error: ‘ios’ has not been declared 21 | ios::sync_with_stdio(0); | ^~~ answer.code:22:9: error: ‘cin’ was not declared in this scope 22 | cin.tie(0); | ^~~ answer.code:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? +++ |+#include <iostream> 1 | //#include <bits/stdc++.h> answer.code:23:9: error: ‘string’ was not declared in this scope 23 | string str; | ^~~~~~ answer.code:1:1: note: ‘std::string’ is defined in header ‘<string>’; did you forget to ‘#include <string>’? +++ |+#include <string> 1 | //#include <bits/stdc++.h> answer.code:25:16: error: ‘vector’ was not declared in this scope 25 | vector<vector<string>> vec = {{}}; | ^~~~~~ answer.code:1:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’? +++ |+#include <vector> 1 | //#include <bits/stdc++.h> answer.code:25:32: error: ‘vec’ was not declared in this scope 25 | vector<vector<string>> vec = {{}}; | ^~~ answer.code:26:9: error: ‘VI’ was not declared in this scope 26 | VI queries; | ^~ answer.code:27:23: error: ‘str’ was not declared in this scope; did you mean ‘std’? 27 | while (cin >> str) | ^~~ | std answer.code:34:25: error: ‘queries’ was not declared in this scope 34 | queries.PB(-1); | ^~~~~~~ answer.code:44:32: error: ‘queries’ was not declared in this scope 44 | cin >> queries[day]; | ^~~~~~~ answer.code:46:25: error: ‘assert’ was not declared in this scope 46 | assert(str == "/>"); | ^~~~~~ answer.code:1:1: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’? +++ |+#include <cassert> 1 | //#include <bits/stdc++.h> answer.code:52:9: error: ‘map’ was not declared in this scope 52 | map<string, int> cnt; | ^~~ answer.code:1:1: note: ‘std::map’ is defined in header ‘<map>’; did you forget to ‘#include <map>’? +++ |+#include <map> 1 | //#include <bits/stdc++.h> answer.code:52:21: error: expected primary-expression before ‘int’ 52 | map<string, int> cnt; | ^~~ answer.code:53:13: error: ‘pair’ was not declared in this scope 53 | set<pair<int, string>> se; | ^~~~ answer.code:1:1: note: ‘std::pair’ is defined in header ‘<utility>’; did you forget to ‘#include <utility>’? +++ |+#include <utility> 1 | //#include <bits/stdc++.h> answer.code:53:9: error: ‘set’ was not declared in this scope 53 | set<pair<int, string>> se; | ^~~ answer.code:1:1: note: ‘std::set’ is defined in header ‘<set>’; did you forget to ‘#include <set>’? +++ |+#include <set> 1 | //#include <bits/stdc++.h> answer.code:53:18: error: expected primary-expression before ‘int’ 53 | set<pair<int, string>> se; | ^~~ answer.code:54:33: error: ‘string’ does not name a type 54 | auto updCnt = [&](const string& s, int d) | ^~~~~~ answer.code:60:10: error: expected ‘)’ before ‘;’ token 60 | }; | ^ | ) answer.code:54:26: note: to match this ‘(’ 54 | auto updCnt = [&](const string& s, int d) | ^ answer.code: In lambda function: answer.code:60:10: error: expected ‘{’ before ‘;’ token 60 | }; | ^ answer.code: In function ‘int main()’: answer.code:63:28: error: ‘string’ does not name a type 63 | for (const string& s : vec[i]) | ^~~~~~ answer.code:66:18: error: expected ‘;’ before ‘if’ 66 | } | ^ | ; 67 | if (i >= 7) | ~~ answer.code:67:17: error: expected primary-expression before ‘if’ 67 | if (i >= 7) | ^~ answer.code:66:18: error: expected ‘;’ before ‘if’ 66 | } | ^ | ; 67 | if (i >= 7) | ~~ answer.code:67:17: error: expected primary-expression before ‘if’ 67 | if (i >= 7) | ^~ answer.code:66:18: error: expected ‘)’ before ‘if’ 66 | } | ^ | ...