답안 #328421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
328421 2020-11-16T13:15:57 Z egas Lightning Rod (NOI18_lightningrod) C++14
11 / 100
2000 ms 158672 KB
#include <bits/stdc++.h>

using namespace std;

bool done[30];

int tt=0;

int solve(vector<pair<int,int> > &v) {

    int res=INT_MAX;

    for(int i=0; i<v.size(); i++) {

        int cnt=0;

        vector<int> temp;

        for(int j=i; j<v.size(); j++) {

            if(!done[j] and abs(v[i].second-v[j].second)>=abs(v[i].first-v[j].first)) {

                done[j]=1;

                cnt++;

                temp.push_back(j);

            }

        }

        for(int j=i; j>=0; j--) {

            if(!done[j] and abs(v[i].second-v[j].second)>=abs(v[i].first-v[j].first)) {

                done[j]=1;

                temp.push_back(j);

                cnt++;

            }

        }

        if(cnt>0) {

            res=min(res,1+solve(v));

        }

        for(int x:temp) {

            done[x]=0;

        }

    }

    if(res==INT_MAX)res=0;

    return res;

}

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    int n;

    cin >> n;

    vector<pair<int,int> > v;

    bool isSub1=true;

    for(int i = 0 ; i < n ; i++) {

        int x;

        cin >> x;

        int y;

        cin >> y;

        if(y!=1)isSub1=false;

        v.push_back({x,y});

    }

    if(isSub1) {

        cout << n << '\n';

    } else {

        cout << solve(v) << '\n';

    }

    return 0;

}

Compilation message

lightningrod.cpp: In function 'int solve(std::vector<std::pair<int, int> >&)':
lightningrod.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0; i<v.size(); i++) {
      |                  ~^~~~~~~~~
lightningrod.cpp:19: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]
   19 |         for(int j=i; j<v.size(); j++) {
      |                      ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1724 ms 131824 KB Output is correct
2 Correct 1738 ms 131732 KB Output is correct
3 Correct 1675 ms 131880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Execution timed out 2071 ms 364 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Execution timed out 2071 ms 364 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Execution timed out 2071 ms 364 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1841 ms 158672 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1724 ms 131824 KB Output is correct
2 Correct 1738 ms 131732 KB Output is correct
3 Correct 1675 ms 131880 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Execution timed out 2071 ms 364 KB Time limit exceeded
12 Halted 0 ms 0 KB -