Submission #62347

# Submission time Handle Problem Language Result Execution time Memory
62347 2018-07-28T08:02:55 Z win11905 Pictionary (COCI18_pictionary) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int, int>
#define x first
#define y second

const int N = 1e5+5;

int n, m, q;
int L[N], R[N], X[N], Y[N], P[N];
vector<int> ls[N];

int find(int x) { return P[x] = P[x] == x ? x : find(P[x]); }

int main() {    
    scanf("%d %d %d", &n, &m, &q);
    for(int i = 0; i < q; ++i) scanf("%d %d", X+i, Y+i), L[i] = 1, R[i] = m;
    bool status = true;
    for(int it = 0; it < 18; ++it) {
        iota(P, P + N, 0);
        for(int i = 0; i < q; ++i) if(L[i] < R[i]) ls[L[i]+R[i] >> 1].emplace(i);
        for(int i = 1; i <= m; ++i) {
            int z = m - i + 1;
            for(int i = z + z; i <= n; i += z) {
                int u = find(z), v = find(i);
                if(u != v) P[u] = v;
            }
            for(auto now : ls[i]) {
                if(find(X[now]) == find(Y[now])) R[now] = i;
                else L[now] = i+1; 
            }
            ls[i].clear();
        }
    }
    for_each(R, R + q, [](int x) { printf("%d\n", x); });
}

Compilation message

pictionary.cpp: In function 'int main()':
pictionary.cpp:22:59: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         for(int i = 0; i < q; ++i) if(L[i] < R[i]) ls[L[i]+R[i] >> 1].emplace(i);
                                                       ~~~~^~~~~
pictionary.cpp:22:80: error: no matching function for call to 'std::vector<int>::emplace(int&)'
         for(int i = 0; i < q; ++i) if(L[i] < R[i]) ls[L[i]+R[i] >> 1].emplace(i);
                                                                                ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from pictionary.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:997:2: note: candidate: template<class ... _Args> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::emplace(std::vector<_Tp, _Alloc>::const_iterator, _Args&& ...) [with _Args = {_Args ...}; _Tp = int; _Alloc = std::allocator<int>]
  emplace(const_iterator __position, _Args&&... __args)
  ^~~~~~~
/usr/include/c++/7/bits/stl_vector.h:997:2: note:   template argument deduction/substitution failed:
pictionary.cpp:22:80: note:   cannot convert 'i' (type 'int') to type 'std::vector<int>::const_iterator {aka __gnu_cxx::__normal_iterator<const int*, std::vector<int> >}'
         for(int i = 0; i < q; ++i) if(L[i] < R[i]) ls[L[i]+R[i] >> 1].emplace(i);
                                                                                ^
pictionary.cpp:19:10: warning: unused variable 'status' [-Wunused-variable]
     bool status = true;
          ^~~~~~
pictionary.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &m, &q);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
pictionary.cpp:18:66: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0; i < q; ++i) scanf("%d %d", X+i, Y+i), L[i] = 1, R[i] = m;
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~