-
Notifications
You must be signed in to change notification settings - Fork 0
/
Question1.cpp
47 lines (45 loc) · 979 Bytes
/
Question1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
using namespace std;
#include <algorithm>
#include <map>
#include <vector>
int main()
{
string s;
getline(cin, s);
string N;
getline(cin, N);
int numN = stoi(N);
map<int, int> mp;
map<int, int> lp;
vector<string> get;
vector<int> data;
for (int i = 0; i < numN; i++)
{
string temp;
cin >> temp;
get.push_back(temp);
}
int p = 0;
while (p < s.size())
{
string tag = s.substr(p, 2);
int numtag = stoi(tag, 0, 16);
//cout << numtag << ":";
p = p + 2;
string len = s.substr(p, 2);
p = p + 2;
int numlen = stoi(len, 0, 16);
//cout << numlen;
lp[numtag] = numlen;
mp[numtag] = p / 2;
p = p + 2 * numlen;
cout << endl;
}
for (int i = 0; i < get.size(); i++)
{
int num = stoi(get[i]);
cout << lp[num] << " " << mp[num] << " " << endl;
}
return 0;
}