Submission #116460

# Submission time Handle Problem Language Result Execution time Memory
116460 2019-06-12T13:49:00 Z oolimry NLO (COCI18_nlo) C++14
66 / 110
263 ms 65536 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    //freopen("i.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long n, m;
    cin >> n >> m;
    typedef pair<long long, long long> ii;

    vector<ii> stuff[n];

    int q;
    cin >> q;
    for(int i = 0;i < n;i++){
        stuff[i].push_back(ii(0,0));
        stuff[i].push_back(ii(m,0));
    }
    for(int qq = 1;qq <= q;qq++){
        long long x, y, r;
        cin >> y >> x >> r;
        x--;
        y--;

        for(int i = y - r;i <= y + r;i++){
            long long dy = abs(i - y);
            long long dx = sqrt(r * r - dy * dy);

            //cout << dx << " " << dy << " " << r << "\n";
            stuff[i].push_back(ii(x - dx,qq));
            stuff[i].push_back(ii(x + dx + 1,-1 * qq));
        }
    }
    long long ans = 0;
    for(int i = 0;i < n;i++){
        sort(stuff[i].begin(),stuff[i].end());

        set<long long> values;

        for(int j = 0;j < stuff[i].size();j++){
            if(j != 0 && stuff[i][j].first != stuff[i][j-1].first){
                set<long long>::iterator it = values.end();
                it--;
                long long v1 = q - *it;
                long long v2 = stuff[i][j].first - stuff[i][j-1].first;
                ans += v1 * v2;


                //cout << ans << " ";
            }

            if(stuff[i][j].second >= 0){
                values.insert(stuff[i][j].second);
            }
            else{
                values.erase(-1 * stuff[i][j].second);
            }

        }
        //cout << ans << "\n";
    }
    cout << ans;
    return 0;
}

Compilation message

nlo.cpp: In function 'int main()':
nlo.cpp:43:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0;j < stuff[i].size();j++){
                       ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1024 KB Output is correct
2 Correct 16 ms 2688 KB Output is correct
3 Correct 11 ms 2816 KB Output is correct
4 Correct 71 ms 14040 KB Output is correct
5 Correct 53 ms 12032 KB Output is correct
6 Runtime error 263 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Correct 202 ms 38392 KB Output is correct
8 Runtime error 257 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 236 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 231 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)