-
Notifications
You must be signed in to change notification settings - Fork 0
/
Correctoutput
144 lines (114 loc) · 2.76 KB
/
Correctoutput
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <vector>
#include <iostream>
#include <unordered_map>
#include <queue>
#include <limits.h>
#include <string>
using namespace std;
class Edge {
public:
int edge_node1_id; //node* edge_node1
int edge_node2_id; //node* edge_node2
int edge_id; //边的编号
int edge_d; //边的d大小
vector<int> tunnelleft;
Edge(int a, int b, int d,int id,int p); // 构造函数,两个点,和一条d
void addEdge();
};
//类的非const静态变量需要全局定义
Edge::Edge(int a, int b, int d,int id,int p) :edge_node1_id(a), edge_node2_id(b), edge_d(d) {
//确定通道的size
edge_id = id;
tunnelleft.resize(p);
}
void Edge::addEdge(){
for(int ii:tunnelleft){
ii=ii+1;
}
}
class Graph{
int P;
int id;
vector<vector<int>> adj; //邻接表
vector<unordered_map< int, Edge*> > Edge_classfy_bynodeid;
Graph(int p,int n,int iid=0){
P = p;
id = iid;
Edge_classfy_bynodeid.resize(n);
}
void addgraphedge(int a,int b,int d);
};
void Graph::addgraphedge(int a,int b,int d){
if( Edge_classfy_bynodeid[a].find(b) != Edge_classfy_bynodeid[a].end()){
Edge_classfy_bynodeid[a][b]->addEdge();
}
Edge* edge = new Edge(a,b,d,id++,P);
Edge_classfy_bynodeid[a][b] = edge;
Edge_classfy_bynodeid[b][a] = edge;
}
void addcost(vector<long long int> &costall,long long int bigger){
long long int st = 1;
for(int _=0;_<60;_++){
st = st<<1;
}
while(bigger > st){
costall.insert(costall.begin(),st);
bigger -= st;
}
if(costall[0] < st){
costall[0] += bigger;
}
else{
costall.insert(costall.begin(),st);
}
}
vector<int> getint(string a){
vector<int> ans;
int size;
int n=0;
for(auto ii:a){
switch(ii){
case ' ': size+=1;
ans.push_back(n);
n=0;
break;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '0': n=n*10 + (ii-'0');
}
if(size == 3){
break;
}
}
return ans;
}
int main(){
int size;
int size_cost = 1000000;
int amplifier_cost = 100;
cin>>size;
vector<long long int> costall = {0};
addcost(costall,size*size_cost);
int nul1,nul2;
for(int ii=0;ii<size;ii++){
cin>>nul1>>nul2;
}
cin.ignore(INT_MAX, '\n');
string neline;
while( getline(cin,neline) ){
vector<int> cal = getint(neline);
addcost(costall,cal[1]);
addcost(costall,cal[2]*amplifier_cost);
for(auto ii:costall){
cout<<ii;
}
cout<<endl;
}
}