Advertisement
artemgf

Складская задача

Nov 30th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.95 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <string>
  4. #include <map>
  5. #include <set>
  6. #include <algorithm>
  7. #include <vector>
  8. #include <stdio.h>
  9. #include <cmath>
  10. #include <math.h>
  11. #include <queue>
  12. #include <stack>
  13. #include <climits>
  14. #include <deque>
  15. #include <ctime>
  16.  
  17. using namespace std;
  18.  
  19. typedef long long ll;
  20. typedef unsigned long long ull;
  21. typedef unsigned int ui;
  22.  
  23. #define mh() make_heap()
  24. #define poph() pop_heap()
  25. #define pushh() push_heap()
  26. #define sor(n) n.begin(), n.end()
  27. #define mp make_pair
  28. #define files freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout)
  29.  
  30. #define formx(a1,b1,c1,a2,b2,c2) ((a1*c2-a2*c1)/(a1*b2-b1*a2))
  31. #define formy(a1,b1,c1,a2,b2,c2) ((c1*b2-c2*b1)/(a1*b2-b1*a2))
  32. #define forma(y1,y2) (y2-y1)
  33. #define formb(x1,x2) (x1-x2)
  34. #define formc(x1,y1,x2,y2) (x1*(y2-y1)-y1*(x2-x1))
  35. #define ras(x1,y1,x2,y2) sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
  36.  
  37. struct cord
  38. {
  39.     double x1, y1, x2, y2;
  40. };
  41. struct limcord
  42. {
  43.     double x, y;
  44.     bool good;
  45. };
  46.  
  47. bool checkparal(double a1, double a2, double b1, double b2)
  48. {
  49.     return a1 / b1 == a2 / b2;
  50. }
  51.  
  52. limcord findt(cord c, cord now)
  53. {
  54.     double a1 = forma(now.y1, now.y2);
  55.     double b1 = formb(now.x1, now.x2);
  56.     double c1 = formc(now.x1, now.y1, now.x2, now.y2);
  57.     double a2 = forma(c.y1, c.y2);
  58.     double b2 = formb(c.x1, c.x2);
  59.     double c2 = formc(c.x1, c.y1, c.x2, c.y2);
  60.  
  61.     if (!checkparal(a1, a2, b1, b2))
  62.     {
  63.         double x = formx(a1, b1, c1, a2, b2, c2);
  64.         double y = formy(a1, b1, c1, a2, b2, c2);
  65.         return{ x,y, true };
  66.     }
  67.     else
  68.     {
  69.         return{ NULL,NULL, false };
  70.     }
  71. }
  72.  
  73. bool checkT(limcord now, cord ot)
  74. {
  75.     if (ras(ot.x1, ot.y1, ot.x2, ot.y2) == ras(ot.x1, ot.y1, now.x, now.y) + ras(ot.x2, ot.y2, now.x, now.y))
  76.         return true;
  77.     else
  78.         return false;
  79. }
  80.  
  81. string check(map<int, set<string>> dic, string word)
  82. {
  83.     if (dic.find(word.size()) != dic.end())
  84.         if (dic[word.size()].find(word) != dic[word.size()].end())
  85.             return word;
  86.         else
  87.         {
  88.             for (auto i = dic[word.size()].begin(); i != dic[word.size()].end(); i++)
  89.             {
  90.                 int s = 0;
  91.                 string prom = *i;
  92.                 for (int j = 0; j <= i->size() - 1; j++)
  93.                 {
  94.                     if (word[j] != prom[j])
  95.                         s++;
  96.                 }
  97.                 if (s == 1)
  98.                     return prom;
  99.             }
  100.         }
  101.     return word;
  102. }
  103.  
  104. vector <ll> fib;
  105. void aadfib()
  106. {
  107.     fib.push_back(1);
  108.     fib.push_back(1);
  109.     for (int i = 3; i <= 1e7; i++)
  110.     {
  111.         fib.push_back(fib[i - 1] + fib[i - 2]);
  112.     }
  113. }
  114. int main()
  115. {
  116.     //files;
  117.     /*int n;
  118.     string text;
  119.     map<int, set<string>> dic;
  120.     string prom;
  121.     vector <string> answ;
  122.  
  123.     cin >> prom;
  124.     while (prom != "#")
  125.     {
  126.         dic[prom.size()].insert(prom);
  127.         cin >> prom;
  128.     }
  129.     int corr = 0;
  130.     getline(cin, prom);
  131.     while (getline(cin, prom))
  132.     {
  133.         string word;
  134.         char lasts = 0;
  135.         int last = 0;
  136.         string line = "";
  137.         for (int i = 0; i <= prom.size() - 1; i++)
  138.         {
  139.             if (prom[i] < 'a' || prom[i] > 'z')
  140.                 if (lasts >= 'a'&&lasts <= 'z')
  141.                 {
  142.                     word = prom.substr(last, i - last);
  143.                     string o = word;
  144.                     word = check(dic, word);
  145.                     if (o != word)
  146.                         corr++;
  147.                     line += word;
  148.                     line += prom[i];
  149.                 }
  150.                 else
  151.                     line += prom[i];
  152.             else
  153.                 if (i == prom.size() - 1)
  154.                 {
  155.                     if (prom[i] == 13)
  156.                     {
  157.                         prom = "";
  158.                         break;
  159.                     }
  160.                     else
  161.                     {
  162.                         word = prom.substr(last, i - last + 1);
  163.                         string o = word;
  164.                         word = check(dic, word);
  165.                         if (o != word)
  166.                             corr++;
  167.                         line += word;
  168.                     }
  169.                 }
  170.                 else
  171.                     if (lasts < 'a' || lasts > 'z')
  172.                         last = i;
  173.             lasts = prom[i];
  174.         }
  175.         answ.push_back(line);
  176.     }
  177.  
  178.     for (auto i = answ.begin(); i != answ.end(); i++)
  179.     {
  180.         cout << *i << endl;
  181.     }
  182.     cout << corr;*/
  183.     ios_base::sync_with_stdio(0);
  184.     cin.tie(0), cout.tie(0);
  185.     int n, m, k;
  186.     cin >> n >> k >> m;
  187.     int prom;
  188.     int p;
  189.     ll sum = 0;
  190.     cout << "YES" << endl;
  191.     for (int i = 1; i <= k; i++)
  192.     {
  193.         cin >> p;
  194.         sum = 0;
  195.         for (int j = 1; j <= p; j++)
  196.         {
  197.             cin >> prom;
  198.             sum += prom;
  199.         }
  200.         cout << sum%(n+1)+1 << endl;
  201.     }
  202.  
  203.    
  204.     return 0;
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement