Submission #62349

# Submission time Handle Problem Language Result Execution time Memory
62349 2018-07-28T08:06:02 Z win11905 Garaža (COCI17_garaza) C++11
0 / 160
80 ms 7756 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;
    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_back(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

garaza.cpp: In function 'int main()':
garaza.cpp:21: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_back(i);
                                                       ~~~~^~~~~
garaza.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);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
garaza.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;
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 3832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 60 ms 3832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 6064 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 7756 KB Output isn't correct
2 Halted 0 ms 0 KB -