Submission #743148

# Submission time Handle Problem Language Result Execution time Memory
743148 2023-05-17T08:21:21 Z vjudge1 Lightning Rod (NOI18_lightningrod) C++17
40 / 100
2000 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> v;

bool sorted(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.second == b.second)
        return a.first > b.first;
    return a.second > b.second;
}

bool check(int x1, int x2, int y1, int y2)
{
    return abs(x1 - x2) <= y1 - y2;
}

inline void read(int &x)
{
    x = 0;
    char ch = getchar_unlocked();
    while (ch & 16)
    {
        x = (x << 3) + (x << 1) + (ch & 15);
        ch = getchar_unlocked();
    }
}

int main()
{
    // bf
    map<int, int> ma;
    map<int, int> poled;
    int n, a, b;
    read(n);
    for (int i = 1; i <= n; ++i)
    {
        read(a);
        read(b);
        v.push_back({a, b});
        ma[i - 1] = -1;
        poled[i - 1] = 0;
    }
    sort(v.begin(), v.end(), sorted);
    for (int i = 0; i < v.size(); ++i)
    {
        for (int j = 0; j < v.size(); ++j)
        {
            if (i != j && check(v[i].first, v[j].first, v[i].second, v[j].second))
            {
                ma[j] = i;
            }
        }
    }
    long long sum = 0;
    for (auto it = ma.begin(); it != ma.end(); ++it)
    {
        if (it->second == -1)
        {
            sum++;
            poled[it->first] = 1;
        }
        else
        {
            poled[it->first] = 1;
        }
    }
    cout << sum;
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i = 0; i < v.size(); ++i)
      |                     ~~^~~~~~~~~~
lightningrod.cpp:46: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]
   46 |         for (int j = 0; j < v.size(); ++j)
      |                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1205 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 57 ms 468 KB Output is correct
12 Correct 14 ms 468 KB Output is correct
13 Correct 14 ms 496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 57 ms 468 KB Output is correct
12 Correct 14 ms 468 KB Output is correct
13 Correct 14 ms 496 KB Output is correct
14 Execution timed out 2084 ms 18968 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1189 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1205 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -