Submission #200918

#TimeUsernameProblemLanguageResultExecution timeMemory
200918SamAndPlahte (COCI17_plahte)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 80004; struct ban { int x; int ty; int i; ban(){} ban(int x, int ty, int i) { this->x = x; this->ty = ty; this->i = i; } }; bool operator<(const ban& a, const ban& b) { if (a.x < b.x) return true; if (a.x > b.x) return false; return a.ty < b.ty; } int n, m; int x1[N], y1[N], x2[N], y2[N]; int x[N], y[N], g[N]; int t[N * 12]; void shi(int pos) { if (t[pos] == -1) return; t[pos * 2] = t[pos]; t[pos * 2 + 1] = t[pos]; t[pos] = -1; } void ubd(int tl, int tr, int l, int r, int y, int pos) { if (l > r) return; if (tl == l && tr == r) { t[pos] = y; return; } shi(pos); int m = (tl + tr) / 2; ubd(tl, m, l, min(m, r), y, pos * 2); ubd(m + 1, tr, max(m + 1, l), r, y, pos * 2 + 1); } int qry(int tl, int tr, int x, int pos) { if (tl == tr) return t[pos]; shi(pos); int m = (tl + tr) / 2; if (x <= m) return qry(tl, m, x, pos * 2); else return qry(m + 1, tr, x, pos * 2 + 1); } int p[N]; int u[N]; vector<int> a[N]; int ans[N]; set<int> s[N]; void dfs(int x) { for (int i = 0; i < a[x].size(); ++i) { int h = a[x][i]; dfs(h); if (s[h].size() > s[x].size()) swap(s[x], s[h]); for (set<int>::iterator it = s[h].begin(); it != s[h].end(); ++it) s[x].insert(*it); } ans[x] = s[x].size(); } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; ++i) scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]); for (int i = 1; i <= m; ++i) scanf("%d%d%d", &x[i], &y[i], &g[i]); /////////////////////////////////////////////////////// vector<int> vv; map<int, int> mp; int z = 0; for (int i = 1; i <= n; ++i) { vv.push_back(y1[i]); vv.push_back(y2[i]); } for (int i = 1; i <= m; ++i) vv.push_back(y[i]); sort(vv.begin(), vv.end()); for (int i = 0; i < vv.size(); ++i) { if (!i || vv[i] != vv[i - 1]) mp[vv[i]] = ++z; } for (int i = 1; i <= n; ++i) { y1[i] = mp[y1[i]]; y2[i] = mp[y2[i]]; } for (int i = 1; i <= m; ++i) y[i] = mp[y[i]]; //////////////////////////////////////////////////////////// vector<ban> v; for (int i = 1; i <= n; ++i) { v.push_back(ban(x1[i], 0, i)); v.push_back(ban(x2[i], 2, i)); } for (int i = 1; i <= m; ++i) { v.push_back(ban(x[i], 1, i)); } sort(v.begin(), v.end()); for (int ii = 0; ii < v.size(); ++ii) { int ty = v[ii].ty; int i = v[ii].i; if (ty == 0) { p[i] = qry(1, z, y1[i], 1); ubd(1, z, y1[i], y2[i], i, 1); } else if (ty == 1) { u[i] = qry(1, z, y[i], 1); } else { ubd(1, z, y1[i], y2[i], p[i], 1); } } //////////////////////////////////////////////// for (int i = 1; i <= n; ++i) a[p[i]].push_back(i); for (int i = 1; i <= m; ++i) s[u[i]].insert(g[i]); dfs(0); for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]); return 0; }

Compilation message (stderr)

plahte.cpp:27:16: error: 'int y1 [80004]' redeclared as different kind of symbol
 int x1[N], y1[N], x2[N], y2[N];
                ^
In file included from /usr/include/features.h:367:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533,
                 from /usr/include/c++/7/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from plahte.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:251:1: note: previous declaration 'double y1(double)'
 __MATHCALL (y1,, (_Mdouble_));
 ^
plahte.cpp: In function 'void dfs(int)':
plahte.cpp:74:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a[x].size(); ++i)
                     ~~^~~~~~~~~~~~~
plahte.cpp: In function 'int main()':
plahte.cpp:90:40: warning: pointer to a function used in arithmetic [-Wpointer-arith]
         scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
                                        ^
plahte.cpp:90:57: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'double (*)(double) noexcept' [-Wformat=]
         scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
                                   ~~~~~~                ^
plahte.cpp:99:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
         vv.push_back(y1[i]);
                          ^
plahte.cpp:99:27: error: no matching function for call to 'push_back(double (&)(double) noexcept)'
         vv.push_back(y1[i]);
                           ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/functional:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from plahte.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int] <near match>
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   conversion of argument 1 would be ill-formed:
plahte.cpp:99:26: error: invalid conversion from 'double (*)(double) noexcept' to 'std::vector<int>::value_type {aka int}' [-fpermissive]
         vv.push_back(y1[i]);
                      ~~~~^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/functional:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from plahte.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int] <near match>
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   conversion of argument 1 would be ill-formed:
plahte.cpp:99:26: error: invalid conversion from 'double (*)(double) noexcept' to 'std::vector<int>::value_type {aka int}' [-fpermissive]
         vv.push_back(y1[i]);
                      ~~~~^
plahte.cpp:105:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < vv.size(); ++i)
                     ~~^~~~~~~~~~~
plahte.cpp:112:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
         y1[i] = mp[y1[i]];
             ^
plahte.cpp:112:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
         y1[i] = mp[y1[i]];
                        ^
plahte.cpp:112:19: error: ambiguous overload for 'operator[]' (operand types are 'std::map<int, int>' and 'double(double) noexcept')
         y1[i] = mp[y1[i]];
                   ^
In file included from /usr/include/c++/7/map:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:81,
                 from plahte.cpp:1:
/usr/include/c++/7/bits/stl_map.h:484:7: note: candidate: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int] <near match>
       operator[](const key_type& __k)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_map.h:484:7: note:   conversion of argument 1 would be ill-formed:
plahte.cpp:112:24: error: invalid conversion from 'double (*)(double) noexcept' to 'std::map<int, int>::key_type {aka int}' [-fpermissive]
         y1[i] = mp[y1[i]];
                    ~~~~^
In file included from /usr/include/c++/7/map:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:81,
                 from plahte.cpp:1:
/usr/include/c++/7/bits/stl_map.h:504:7: note: candidate: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int] <near match>
       operator[](key_type&& __k)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_map.h:504:7: note:   conversion of argument 1 would be ill-formed:
plahte.cpp:112:24: error: invalid conversion from 'double (*)(double) noexcept' to 'std::map<int, int>::key_type {aka int}' [-fpermissive]
         y1[i] = mp[y1[i]];
                    ~~~~^
plahte.cpp:129:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int ii = 0; ii < v.size(); ++ii)
                      ~~~^~~~~~~~~~
plahte.cpp:135:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
             p[i] = qry(1, z, y1[i], 1);
                                  ^
plahte.cpp:135:34: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
             p[i] = qry(1, z, y1[i], 1);
                              ~~~~^
plahte.cpp:54:5: note:   initializing argument 3 of 'int qry(int, int, int, int)'
 int qry(int tl, int tr, int x, int pos)
     ^~~
plahte.cpp:136:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
             ubd(1, z, y1[i], y2[i], i, 1);
                           ^
plahte.cpp:136:27: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
             ubd(1, z, y1[i], y2[i], i, 1);
                       ~~~~^
plahte.cpp:40:6: note:   initializing argument 3 of 'void ubd(int, int, int, int, int, int)'
 void ubd(int tl, int tr, int l, int r, int y, int pos)
      ^~~
plahte.cpp:144:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
             ubd(1, z, y1[i], y2[i], p[i], 1);
                           ^
plahte.cpp:144:27: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
             ubd(1, z, y1[i], y2[i], p[i], 1);
                       ~~~~^
plahte.cpp:40:6: note:   initializing argument 3 of 'void ubd(int, int, int, int, int, int)'
 void ubd(int tl, int tr, int l, int r, int y, int pos)
      ^~~
plahte.cpp:88:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
plahte.cpp:90:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plahte.cpp:92:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &x[i], &y[i], &g[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~