Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- a = int(input())
- arr = []
- for i in range(a):
- t = input().split(',')
- count = 0
- c = set()
- for i in range(3):
- for x in t[i]:
- if not x in c:
- count += 1
- c.add(x)
- """c = [False] * 52
- for i in range(3):
- for x in t[i]:
- if 'A' <= x <= 'Z':
- if not c[ord(x) - ord('A')]:
- count += 1
- c[ord(x) - ord('A')] = True
- else:
- if not c[ord(x) - ord('a') + 26]:
- count += 1
- c[ord(x) - ord('a') + 26] = True"""
- c2 = 0
- for i in range(3, 5):
- for x in t[i]:
- c2 += int(x)
- c2 *= 64
- c3 = ord(t[0][0]) - ord('A') + 1 if 'A' <= t[0][0] <= 'Z' else ord(t[0][0]) - ord('a') + 1
- c3 *= 256
- res = count + c2 + c3
- tmp = 16 * 16
- res %= tmp * 16
- s = ""
- while not tmp == 0:
- i = res // tmp
- res %= tmp
- #print(i)
- if i < 10:
- s += str(i)
- else:
- s += chr(ord('A') + i % 10)
- tmp //= 16
- print(s, end=' ')
- if __name__ == '__main__':
- main()
- #include <iostream>
- #include <algorithm>
- #include <map>
- #include <vector>
- using namespace std;
- struct Date{
- int day;
- int hour;
- int minute;
- };
- int main() {
- map<int, vector<pair<Date, char>>> logs;
- int LogCount;
- cin >> LogCount;
- for(int i = 0; i < LogCount; ++i){
- int day, hour, minute, id;
- char status;
- cin >> day >> hour >> minute >> id >> status;
- logs[id].push_back({{day, hour, minute}, status});
- }
- for(auto& x : logs){
- std::sort(x.second.begin(), x.second.end(), [](auto lhs, auto rhs){
- return lhs.first.day < rhs.first.day
- || (lhs.first.day == rhs.first.day && (lhs.first.hour < rhs.first.hour || ( lhs.first.hour == rhs.first.hour && lhs.first.minute < rhs.first.minute)));
- });
- }
- for(const auto& x : logs){
- long long count = 0;
- Date date_begin = {0, 0, 0};
- Date date_end = {0, 0, 0};
- for(const auto& i : x.second){
- if(i.second == 'A')
- date_begin = i.first;
- if(i.second == 'C' || i.second == 'S') {
- date_end = i.first;
- count += (date_end.day*1440 + date_end.hour*60 + date_end.minute - (date_begin.day*1440 + date_begin.hour*60 + date_begin.minute));
- }
- }
- cout << count << ' ';
- }
- }
- #include<bits/stdc++.h>
- #define LINT long long int
- using namespace std;
- struct ListNode {
- int val;
- ListNode *left;
- ListNode *right;
- ListNode *pred;
- ListNode() : val(0), left(nullptr), right(nullptr), pred(nullptr){}
- ListNode(int x) : val(x), left(nullptr), right(nullptr), pred(nullptr) {}
- ListNode(int x, ListNode *left, ListNode *right, ListNode *pred) : val(x), left(left), right(right), pred(pred){}
- };
- vector<ListNode*> vc;
- void create_node(ListNode* head, int index, int s) {
- vc[index] = head;
- if (index * 2 <= s) {
- ListNode* left = new ListNode(index * 2, nullptr, nullptr, head);
- head->left = left;
- create_node(left, index * 2, s);
- }
- if (index * 2 + 1 <= s) {
- ListNode* right = new ListNode(index * 2 + 1, nullptr, nullptr, head);
- head->right = right;
- create_node(right, index * 2 + 1, s);
- }
- }
- ListNode* create_tree(int s) {
- if (s == 0)
- return nullptr;
- ListNode* root = new ListNode(1);
- create_node(root, 1, s);
- return root;
- }
- void print_node(ListNode* head) {
- if (head->left != nullptr)
- print_node(head->left);
- cout << head->val << ' ';
- if (head->right != nullptr)
- print_node(head->right);
- }
- int main()
- {
- int a;
- cin >> a;
- vc.resize(a + 1);
- ListNode* root = create_tree(a);
- int b;
- cin >> b;
- for (int i = 0; i < b; ++i) {
- int t;
- cin >> t;
- ListNode* v = vc[t];
- if (v->pred == nullptr)
- continue;
- ListNode* p = v->pred;
- if (p == root)
- root = v;
- v->pred = p->pred;
- if (p->pred != nullptr) {
- if (p->pred->right == p)
- p->pred->right = v;
- else
- p->pred->left = v;
- }
- p->pred = v;
- if (p->right == v) { // its right
- p->right = v->right;
- if (p->right != nullptr)
- p->right->pred = p;
- v->right = p;
- if (v->right != nullptr)
- v->right->pred = v;
- } else {
- p->left = v->left;
- if (p->left != nullptr)
- p->left->pred = p;
- v->left = p;
- if (v->left != nullptr)
- v->left->pred = v;
- }
- }
- print_node(root);
- }
- #include<bits/stdc++.h>
- #define LINT long long int
- using namespace std;
- struct Comp {
- int start_time;
- int end_time;
- int cost;
- Comp(int s, int e, int c) : start_time(s), end_time(e), cost(c){}
- Comp() : start_time(0), end_time(0), cost(0){}
- };
- int main()
- {
- int a;
- cin >> a;
- vector<pair<int, LINT> > s; // cost
- vector<pair<int, LINT> > s1; // time
- vector<Comp> vc(a, *(new Comp()));
- for (auto& x : vc) {
- cin >> x.start_time >> x.end_time >> x.cost;
- }
- sort(vc.begin(), vc.end(), [](Comp& a, Comp& b){return a.start_time < b.start_time;});
- LINT prev = 0;
- for (const auto& x : vc) {
- prev += x.cost;
- s.push_back({x.start_time, prev});
- }
- sort(vc.begin(), vc.end(), [](Comp& a, Comp& b){return a.end_time < b.end_time;});
- prev = 0;
- for (const auto& x : vc) {
- prev += x.end_time - x.start_time;
- s1.push_back({x.end_time, prev});
- }
- int b;
- cin >> b;
- for (int i = 0; i < b; ++i) {
- int a1, a2, a3;
- cin >> a1 >> a2 >> a3;
- if (a3 == 1) {
- auto l = upper_bound(s.begin(), s.end(), pair<int, LINT>({a1, INT64_MIN}));
- auto r = upper_bound(l, s.end(), pair<int, LINT>({a2, INT64_MAX}));
- if (r == s.begin()) {
- cout << 0 << ' ';
- continue;
- }
- if (l == s.begin()) {
- r--;
- cout << r->second << ' ';
- continue;
- }
- l--;
- r--;
- cout << r->second - l->second << ' ';
- } else {
- auto l = upper_bound(s1.begin(), s1.end(), pair<int, LINT>({a1, INT64_MIN}));
- auto r = upper_bound(l, s1.end(), pair<int, LINT>({a2, INT64_MAX}));
- if (r == s1.begin()) {
- cout << 0 << ' ';
- continue;
- }
- if (l == s1.begin()) {
- r--;
- cout << r->second << ' ';
- continue;
- }
- l--;
- r--;
- cout << r->second - l->second << ' ';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement