func_code_string: #include <bits/stdc++.h>   using namespace std;   class MinCostMaxFlowLongLong {    public:     class MinCostMaxFlowEdge {      private:       int destination_;       long long capacity_;       long long cost_;       long long flow_;         public:       MinCostMaxFlowEdge(int destination, long long capacity, long long cost) {         this->destination_ = destination;         this->capacity_ = capacity;         this->cost_ = cost;         this->flow_ = 0L;       }       MinCostMaxFlowEdge(MinCostMaxFlowEdge& ref) {         this->destination_ = ref.destination();         this->capacity_ = ref.capacity();         this->cost_ = ref.cost();         this->flow_ = ref.flow();       }       int destination() { return destination_; }       long long capacity() { return capacity_; }       long long cost() { return cost_; }       long long flow() { return flow_; }       void setFlow(long long flow) { flow_ = flow; }     };     vector<vector<MinCostMaxFlowEdge*> > adj_;     vector<long long> supply_;     MinCostMaxFlowLongLong(int node_count) {       supply_ = vector<long long>(node_count, 0LL);       adj_ = vector<vector<MinCostMaxFlowEdge*> >(node_count,                                                   vector<MinCostMaxFlowEdge*>());     }     void addEdge(int from, int to, long long capacity, long long cost) {       adj_[from].push_back(new MinCostMaxFlowEdge(to, capacity, cost));     }     void setSupply(int node, long long amount) { supply_[node] = amount; }     long long solve(long long fail_value, long long kHuge = 2120120123LL) {       int n = ((int)(supply_).size());       vector<vector<MinCostMaxFlowEdge*> > adjcopy = adj_;       for (int i = 0; i < ((int)(adj_).size()); ++i) {         for (int j = 0; j < ((int)(adj_[i]).size()); ++j) {           adjcopy[i][j] = new MinCostMaxFlowEdge(*(adj_[i][j]));         }       }       vector<long long> supplycopy = supply_;       for (int i = 0; i < n; ++i) {         if (i > 0) {           adjcopy[0].push_back(new MinCostMaxFlowEdge(i, kHuge, kHuge));           adjcopy[i].push_back(new MinCostMaxFlowEdge(0, kHuge, kHuge));         }       }       vector<vector<MinCostMaxFlowEdge*> > reverse_adj(           n, vector<MinCostMaxFlowEdge*>());       for (int i = 0; i < n; ++i) {         for (int j = 0; j < ((int)(adjcopy[i]).size()); ++j) {           reverse_adj[i].push_back(NULL);         }       }       for (int i = 0; i < n; ++i) {         for (int j = 0; j < ((int)(adjcopy[i]).size()); ++j) {           if (reverse_adj[i][j] == NULL) {             int destination = adjcopy[i][j]->destination();             long long cost = adjcopy[i][j]->cost();             MinCostMaxFlowEdge* new_edge = new MinCostMaxFlowEdge(i, 0, -cost);             adjcopy[destination].push_back(new_edge);             reverse_adj[destination].push_back(adjcopy[i][j]);             reverse_adj[i][j] = new_edge;           }         }       }       vector<long long> pi(n, 0LL);       for (int i = 0; i < n; ++i) {         for (int j = 0; j < ((int)(adjcopy[i]).size()); ++j) {           adjcopy[i][j]->setFlow(0);         }       }       long long maximum_flow_at_a_time = -1;       for (int i = 0; i < n; ++i) {         maximum_flow_at_a_time = max(maximum_flow_at_a_time, supplycopy[i]);         for (int j = 0; j < ((int)(adjcopy[i]).size()); ++j) {           maximum_flow_at_a_time =               max(maximum_flow_at_a_time, adjcopy[i][j]->capacity());         }       }       long long delta = 1LL;       while (delta < maximum_flow_at_a_time) delta *= 2LL;       vector<int> pred(n, 0), pred_adj(n, 0);       vector<long long> shortest(n, 0LL);       set<pair<long long, int> > pq;       while (delta >= 1LL) {         for (int i = 0; i < n; ++i) {           for (int j = 0; j < ((int)(adjcopy[i]).size()); ++j) {             if (adjcopy[i][j]->capacity() - adjcopy[i][j]->flow() >= delta &&                 adjcopy[i][j]->cost() - pi[i] + pi[adjcopy[i][j]->destination()] <                     0LL) {               int destination = adjcopy[i][j]->destination();               long long add_flow =                   adjcopy[i][j]->capacity() - adjcopy[i][j]->flow();               supplycopy[i] -= add_flow;               supplycopy[destination] += add_flow;               adjcopy[i][j]->setFlow(adjcopy[i][j]->flow() + add_flow);               reverse_adj[i][j]->setFlow(reverse_adj[i][j]->flow() - add_flow);             }           }         }         for (int i = 0; i < n; ++i) {           while (supplycopy[i] >= delta) {             for (int j = 0; j < n; ++j) {               shortest[j] = -1LL;             }             shortest[i] = 0LL;             pred[i] = -1;             pq.insert(make_pair(0LL, i));             while (!pq.empty()) {               long long top_value = (*(pq.begin())).first;               int node = (*(pq.begin())).second;               pq.erase(pq.begin());               if (shortest[node] < top_value) {                 continue;               }               for (int j = 0; j < ((int)(adjcopy[node]).size()); ++j) {                 if (adjcopy[node][j]->capacity() - adjcopy[node][j]->flow() >=                     delta) {                   int destination = adjcopy[node][j]->destination();                   long long cost = top_value + adjcopy[node][j]->cost() -                                    pi[node] + pi[destination];                   if (shortest[destination] == -1LL ||                       shortest[destination] > cost) {                     pred[destination] = node;                     pred_adj[destination] = j;                     shortest[destination] = cost;                     pq.insert(make_pair(cost, destination));                   }                 }               }             }             int def = -1;             for (int j = 0; j < n; ++j) {               if (supplycopy[j] < 0LL && shortest[j] != -1LL) {                 def = j;                 break;               }             }             for (int j = 0; j < n; ++j) {               if (shortest[j] != -1LL) {                 pi[j] = pi[j] - shortest[j] + shortest[def];               }             }             supplycopy[def] += delta;             supplycopy[i] -= delta;             while (pred[def] != -1) {               int previous = pred[def];               adjcopy[previous][pred_adj[def]]->setFlow(                   adjcopy[previous][pred_adj[def]]->flow() + delta);               reverse_adj[previous][pred_adj[def]]->setFlow(                   reverse_adj[previous][pred_adj[def]]->flow() - delta);               def = previous;             }           }         }         delta /= 2LL;       }       bool feasible = true;       for (int i = 0; i < n; ++i) {         for (int j = ((int)(adj_[i]).size()); j < ((int)(adjcopy[i]).size());              ++j) {           if (adjcopy[i][j]->flow() > 0LL) {             feasible = false;           }         }       }       if (!feasible) {         return fail_value;       }       long long answer = 0;       for (int i = 0; i < n; ++i) {         for (int j = 0; j < ((int)(adjcopy[i]).size()); ++j) {           if (adjcopy[i][j]->flow() > 0LL) {             answer += adjcopy[i][j]->flow() * adjcopy[i][j]->cost();           }         }       }       for (int i = 0; i < n; ++i) {         for (int j = 0; j < ((int)(adj_[i]).size()); ++j) {           adj_[i][j]->setFlow(adjcopy[i][j]->flow());         }       }       return answer;     }   };   int stat[1200];   int en[1200];   int pro[1200];   int ret[1200];   int sid[1200];   int sen[1200];   map<int, int> waktu;   int id = 1;   void Put(int w) {     if (waktu.count(w)) return;     waktu[w] = id;     ++id;   }   int main() {     int n, k;     cin >> n >> k;     for (int(i) = 0; (i) < (n); ++(i)) {       cin >> stat[i] >> en[i] >> pro[i];       en[i] = stat[i] + en[i];       Put(stat[i]);       Put(en[i]);       sid[i] = waktu[stat[i]];       sen[i] = waktu[en[i]];     }     MinCostMaxFlowLongLong mcmf(((int)(waktu).size()) + 2);     int sink = ((int)(waktu).size()) + 1;     assert(id == sink);     int tap = 0;     vector<pair<int, int> > ws;     ws.push_back(make_pair(-1, tap));     ws.push_back(make_pair(2012012012, sink));     for (typeof((waktu).begin()) it = (waktu).begin(); it != (waktu).end();          it++) {       ws.push_back(make_pair(it->first, it->second));     }     sort(ws.begin(), ws.end());     for (int(i) = 0; (i) < (((int)(ws).size()) - 1); ++(i))       mcmf.addEdge(ws[i].second, ws[i + 1].second, 55, 0);     for (int(i) = 0; (i) < (n); ++(i)) {       int ids = waktu[stat[i]];       int ide = waktu[en[i]];       mcmf.addEdge(ids, ide, 1, -pro[i]);     }     mcmf.setSupply(tap, k);     mcmf.setSupply(sink, -k);     bool f = 0;     mcmf.solve(-2023123123);     assert(!f);     for (int(i) = 0; (i) < (((int)(waktu).size()) + 2); ++(i))       for (int(j) = 0; (j) < (((int)(mcmf.adj_[i]).size())); ++(j)) {         if (mcmf.adj_[i][j]->cost() < 0LL && mcmf.adj_[i][j]->flow()) {           int a = i;           int b = mcmf.adj_[i][j]->destination();           int cos = mcmf.adj_[i][j]->cost() * -1;           for (int(kk) = 0; (kk) < (n); ++(kk))             if (!ret[kk] && sid[kk] == a && sen[kk] == b && pro[kk] == cos) {               ret[kk] = 1;               break;             }         }       }     for (int(i) = 0; (i) < (n); ++(i)) {       if (i) cout <<    ;       cout << ret[i];     }     cout << endl;   }   