Submission #799821

# Submission time Handle Problem Language Result Execution time Memory
799821 2023-08-01T05:28:25 Z Trisanu_Das NLO (COCI18_nlo) C++17
110 / 110
555 ms 304 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m, k, X[N], Y[N], R[N];
long long tot;
int main()
{
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= k; i++)
        scanf("%d%d%d", &X[i], &Y[i], &R[i]);
    tot = 1LL * n * m * k;
    for (int i = 1; i <= n; i++)
    {
        set < int > S;
        vector < pair < int , int > > A;
        for (int j = 1; j <= k; j++)
            if (abs(i - X[j]) <= R[j])
            {
                int delta = (int)floor(sqrt(1.0 * R[j] * R[j] - 1.0 * (i - X[j]) * (i - X[j])));
                A.push_back({Y[j] - delta, j});
                A.push_back({Y[j] + delta + 1, -j});
            }
        sort(A.begin(), A.end());
        for (int j = 0; j < A.size(); j++)
        {
            if (S.size())
                tot -= 1LL * (A[j].first - A[j -1].first) * (*S.rbegin());
            if (A[j].second > 0)
                S.insert(A[j].second);
            else
                S.erase(-A[j].second);
        }
    }
    return !printf("%lld\n", tot);
}

Compilation message

nlo.cpp: In function 'int main()':
nlo.cpp:24:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for (int j = 0; j < A.size(); j++)
      |                         ~~^~~~~~~~~~
nlo.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d%d%d", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
nlo.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%d%d%d", &X[i], &Y[i], &R[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 8 ms 212 KB Output is correct
3 Correct 5 ms 212 KB Output is correct
4 Correct 35 ms 304 KB Output is correct
5 Correct 23 ms 300 KB Output is correct
6 Correct 208 ms 292 KB Output is correct
7 Correct 71 ms 212 KB Output is correct
8 Correct 413 ms 300 KB Output is correct
9 Correct 133 ms 288 KB Output is correct
10 Correct 555 ms 292 KB Output is correct