-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8b.cpp
More file actions
57 lines (50 loc) · 964 Bytes
/
8b.cpp
File metadata and controls
57 lines (50 loc) · 964 Bytes
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
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <set>
using namespace std;
set<int> hechas;
vector<pair<string,int>> vect;
int main()
{
string letras;
int cant;
while(cin>>letras>>cant)
{
vect.push_back({letras,cant});
}
/*for(int y=0; y<vect.size();y++){
cout<<vect[y].first<<" "<<vect[y].second<<endl;
}*/
for(int j=0; j<vect.size();j++){
auto vect_copy=vect;
int contador=0;
if(vect_copy[j].first=="nop"){
vect_copy[j].first="jmp";
}else if(vect_copy[j].first=="jmp"){
vect_copy[j].first="nop";
}
int i=0;
int s=0;
while(s<1000 and i<vect.size() and i>=0){
hechas.insert(i);
if(vect_copy[i].first=="acc"){
contador+=vect_copy[i].second;
i++;
}
if(vect_copy[i].first=="nop"){
i++;
}
if(vect_copy[i].first=="jmp"){
i+=vect_copy[i].second;
}
s++;
}
hechas.clear();
if(i==vect_copy.size()){
cout<<contador<<endl;
return 0;
}
}
}