# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
830810 | 2023-08-19T10:55:02 Z | vjudge1 | Lightning Rod (NOI18_lightningrod) | C++17 | 2000 ms | 170112 KB |
#include<bits/stdc++.h> #define ll long long #define fi first #define se second using namespace std; const int nmax = 1e7+7; struct point { int x; int y; int dex; }; bool cmp(point &a, point&b) { return (a.y > b.y); } int par[nmax]; bool soada[nmax] = {false}; set<int>gratis; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; vector<point>tik(N+1); bool sub1=true; bool sub6=true; int hit=0; for(int i=1; i<=N; i++) par[i]=i; for(int i=0; i<N; i++) { cin >> tik[i].x >> tik[i].y; if(i>0 && tik[i].x!=tik[i-1].x) hit++; if(tik[i].y != 1) sub1=false; if(tik[i].y > 1 || tik[i].x!=i) sub6=false; } if(sub1==true) { cout << hit+1 << endl; return 0; } if(sub6==true) { int i=1; int cost = N; while(i<N) { if(tik[i].y==1) { gratis.insert(i-1); gratis.insert(i+1); } i++; } cost-=gratis.size(); cout << cost << endl; return 0; } sort(tik.begin(), tik.end(), cmp); for(int i=0; i<N; i++) { tik[i].dex = i+1; } vector<int>dafter; while(!tik.empty()) { dafter.push_back(0); for(int i=1; i<tik.size(); i++) { if(abs(tik[0].x - tik[i].x) <= tik[0].y-tik[i].y) { par[tik[i].dex] = tik[0].dex; //cout << "par[" << tik[i].dex << "] = " << tik[0].dex << endl; dafter.push_back(i); } } int kur = 0; for(int j=0; j<dafter.size(); j++) { //cout << "dafter " << dafter[j] << endl; tik.erase(tik.begin()+dafter[j]-kur); kur++; } dafter.clear(); } int cost = 0; for(int i=1; i<=N; i++) { if(soada[par[i]]==false) { cost++; soada[par[i]]=true; } } cout << cost << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1178 ms | 170112 KB | Output is correct |
2 | Correct | 1188 ms | 162464 KB | Output is correct |
3 | Correct | 1153 ms | 164404 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 328 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 324 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 328 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 328 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 324 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 328 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 328 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 324 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 328 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 340 KB | Output is correct |
13 | Correct | 6 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 328 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 324 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 328 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 340 KB | Output is correct |
13 | Correct | 6 ms | 340 KB | Output is correct |
14 | Execution timed out | 2045 ms | 7960 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2073 ms | 167036 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1178 ms | 170112 KB | Output is correct |
2 | Correct | 1188 ms | 162464 KB | Output is correct |
3 | Correct | 1153 ms | 164404 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 328 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 324 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 328 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 2 ms | 340 KB | Output is correct |
16 | Correct | 6 ms | 340 KB | Output is correct |
17 | Execution timed out | 2045 ms | 7960 KB | Time limit exceeded |
18 | Halted | 0 ms | 0 KB | - |