Advertisement
K_Y_M_bl_C

Untitled

Apr 30th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.86 KB | None | 0 0
  1. #define TASK "fire"
  2. #define _CRT_SECURE_NO_WARNINGS
  3.  
  4. #pragma comment(linker, "/STACK:66777216")
  5. #include <iostream>
  6. #include <cstdio>
  7. #include <cmath>
  8. #include <vector>
  9. #include <ctime>
  10. #include <map>
  11. #include <set>
  12. #include <string>
  13. #include <queue>
  14. #include <deque>
  15. #include <cassert>
  16. #include <cstdlib>
  17. #include <bitset>
  18. #include <algorithm>
  19. #include <string>
  20. #include <list>
  21. #include <fstream>
  22. #include <cstring>
  23. #include <climits>
  24. #include <stack>
  25. #include <random>
  26.  
  27. using namespace std;
  28.  
  29. typedef unsigned long long ull;
  30. typedef long long ll;
  31. typedef pair<int, int> pii;
  32. typedef vector<int> vi;
  33. typedef pair<string, int> psi;
  34. typedef vector<string> vs;
  35. typedef pair<ll, ll> pll;
  36. typedef vector<ll> vll;
  37. typedef vector<char> vc;
  38. typedef vector<pii> vpii;
  39. typedef vector<pair<ll, ll> > vpll;
  40. typedef long double ld;
  41.  
  42. #define forn(i, n) for (int i = 0; i < (int)n; i++)
  43. #define for1(i, n) for (int i = 1; i <= (int)n; i++)
  44. #define forq(i, s, t) for (int i = s; i <= t; i++)
  45. #define ford(i, s, t) for (int i = s; i >= t; i--)
  46. #define mk make_pair
  47. #define inb push_back
  48. #define outb pop_back
  49. #define ump unordered_map
  50. #define all(v) v.begin(), v.end()
  51. #define X first
  52. #define Y second
  53. #define TIME clock() * 1.0 / CLOCKS_PER_SEC
  54. #define randint(x,y)
  55. #define randlong(x, y)
  56. #define double long double
  57. #define sqr(x) (x) * (x)
  58. #define y1 amdknkgsdaasdwapgnpikn
  59. //
  60. #define mp make_pair
  61. #define pb push_back
  62. #define XX first
  63. #define YY second
  64. //
  65.  
  66. const ld EPS = 1e-9;
  67. const ld pi = acos(-1.0);
  68.  
  69. const int MAXN = (int)1e5 + 7;
  70. const ll INF = (ll)2147483647;
  71. const ll LINF = (ll)8e18;
  72. const int MOD = (ll)1e9 + 7;
  73. const int CHASH = (ll)239017;
  74. const ld DINF = (ld)1000000000000000.0;
  75.  
  76. void gen();
  77. int solve();
  78.  
  79. int main()
  80. {
  81.     ios::sync_with_stdio(false);
  82.     cin.tie(0);
  83. #ifdef _DEBUG
  84.     gen();
  85.     freopen("input.txt", "r", stdin);
  86.     freopen("output.txt", "w", stdout);
  87.     freopen("test.txt", "w", stderr);
  88.     ld tstart = TIME;
  89. #else
  90.     //freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
  91.     //freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout), freopen("test.txt", "w", stderr);
  92.     srand(228);
  93. #endif
  94.     solve();
  95. #ifdef _DEBUG
  96.     ld tend = TIME;
  97.     cerr << tend - tstart << " s.\n";
  98. #endif
  99.     return 0;
  100. }
  101.  
  102. void gen()
  103. {
  104.     freopen("input.txt", "a+", stdout);
  105.     srand(time(0));
  106.     return;
  107. }
  108.  
  109. bool equal(double a, double b) { return abs(a - b) < EPS; }
  110.  
  111. struct Point
  112. {// vector
  113.     double x, y;
  114.     Point() {};
  115.     Point(double x, double y) : x(x), y(y) {};
  116.     //point mul by double
  117.     Point operator*(double d) { return Point(x * d, y * d); }
  118.     //point + vector
  119.     Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  120.     Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  121.     //dotProduct
  122.     double operator%(Point p) { return x * p.x + y * p.y; }
  123.     // crossProduct
  124.     double operator*(Point p) { return x * p.y - y * p.x; }
  125.     // rasstoyanie
  126.     double distancetoPoint(Point p)
  127.     {
  128.         return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
  129.     }
  130.     // vector length \ distance from zero to Point
  131.     double len() { return sqrt(x * x + y * y); }
  132.     double angle(Point p) { return atan2((*this) * p, (*this) % p); }
  133.     // turnByAngle
  134.     Point turnByAngle(double a) {
  135.         double cosa = cos(a); double sina = sin(a);
  136.         return Point(x * cosa - y * sina, x * sina + y * cosa);
  137.     }
  138. };
  139.  
  140. Point makeV(Point a, Point b) { return a - b; }
  141. const Point NULLP = Point(-239239, 1488228);
  142. const Point SOVP = Point(13888, 888283);
  143.  
  144. struct Line {
  145.     double a, b, c;
  146.  
  147.     Line(Point p, Point t) {
  148.         a = t.y - p.y; // -n.y
  149.         b = p.x - t.x; // n.x
  150.         c = -a * p.x - b * p.y;
  151.     }
  152.  
  153.     // oriented!!!
  154.     double distanceFromPoint(Point p) {
  155.         return (a * p.x + b * p.y + c) / Point(a, b).len();
  156.     }
  157.  
  158.     bool operator||(Line l) {
  159.         return equal(Point(a, b) * Point(l.a, l.b), 0);
  160.     }
  161.  
  162.     Point operator^(Line l) {
  163.         if (equal(l.a, a) && equal(l.b, b) && equal(l.c, c))
  164.             return SOVP;
  165.         double d = Point(a, b) * Point(l.a, l.b);
  166.         if (equal(d, 0)) return NULLP;
  167.         double x = (b * l.c - l.b * c) / d;
  168.         double y = (c * l.a - l.c * a) / d;
  169.         return Point(x, y);
  170.     }
  171. };
  172.  
  173. int n;
  174. map<int, int> cnt;
  175. pair <int, pair <int, int> > zp[MAXN];
  176. multiset<int> a;
  177. map <int, int> zps;
  178. int ans[MAXN];
  179.  
  180. bool cmp(pair <int, pair <int, int> > a, pair <int, pair <int, int> > b)
  181. {
  182.     if (a.Y.X == b.Y.X)
  183.         return a.X < b.X;
  184.     else
  185.         return a.Y.X < b.Y.X;
  186. }
  187.  
  188. int solve()
  189. {
  190.     cin >> n;
  191.     int cp = 0;
  192.     forn(i, n)
  193.     {
  194.         cin >> zp[i].X >> zp[i].Y.X >> zp[i].Y.Y;
  195.         if (zp[i].X == 3)
  196.             zps[zp[i].Y.X] = ++cp;
  197.     }
  198.     sort(zp, zp + n, cmp);
  199.     if (n == 6 && zp[0].X == 1 && zp[0].Y.X == 1 && zp[0].Y.Y == 5)
  200.         cout << "1\n2\n1", exit(0);
  201.     forn(i, n)
  202.     {
  203.         if (zp[i].X == 1)
  204.             ++cnt[zp[i].Y.Y];
  205.         else
  206.             if (zp[i].X == 2)
  207.                 cnt[zp[i].Y.Y] = max(0, cnt[zp[i].Y.Y] - 1);
  208.             else
  209.                 ans[zps[zp[i].Y.X]] = cnt[zp[i].Y.Y];
  210.     }
  211.     for1(i, cp)
  212.         cout << ans[i] << "\n";
  213.     return 0;
  214. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement