Submission #1091169

#TimeUsernameProblemLanguageResultExecution timeMemory
1091169IzzyAdvertisement 2 (JOI23_ho_t2)C++14
0 / 100
0 ms348 KiB
#include <iostream> #include <vector> #include <queue> using namespace std; int n; vector<int> visited; vector<pair<int, int>> res; //just count how many graphs there are void traverse(int start) { queue<int> q; q.push(start); visited[start] = false; int a; while (!q.empty()) { a = q.front(); q.pop(); for (int i = -1 * res[a].second; i <= res[a].second; i++) { if (a + i >= 0 && a + i < n) { if (!visited[a + i] && abs(res[a].first - res[a + i].first) <= res[a].second - res[a + i].second) { visited[a + i] = true; q.push(a + i); } else { continue; } } else { break; } } } } int main() { cin >> n; pair<int, int> temp; for (int i = 0; i < n; i++) { cin >> temp.first; cin >> temp.second; res.push_back(temp); visited.push_back(false); } int count = 0; for (int i = 0; i < n; i++) { if (!visited[i]) { traverse(i); count++; } } cout << count; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...