Submission #918259

#TimeUsernameProblemLanguageResultExecution timeMemory
918259devkudawlaLightning Rod (NOI18_lightningrod)C++17
14 / 100
1197 ms78424 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order(it return an iterator input is a value), order_of_key(input is index) typedef tree<long long, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") template <class T> void Distinct(T &v, bool sorting = true) { if (sorting) sort(begin(v), end(v)); v.resize(unique(begin(v), end(v)) - begin(v)); } const int BUF_SZ = 1 << 15; inline namespace Input { char buf[BUF_SZ]; int pos; int len; char next_char() { if (pos == len) { pos = 0; len = (int)fread(buf, 1, BUF_SZ, stdin); if (!len) { return EOF; } } return buf[pos++]; } int read_int() { int x; char ch; int sgn = 1; while (!isdigit(ch = next_char())) { if (ch == '-') { sgn *= -1; } } x = ch - '0'; while (isdigit(ch = next_char())) { x = x * 10 + (ch - '0'); } return x * sgn; } } // namespace Input inline namespace Output { char buf[BUF_SZ]; int pos; void flush_out() { fwrite(buf, 1, pos, stdout); pos = 0; } void write_char(char c) { if (pos == BUF_SZ) { flush_out(); } buf[pos++] = c; } void write_int(int x) { static char num_buf[100]; if (x < 0) { write_char('-'); x *= -1; } int len = 0; for (; x >= 10; x /= 10) { num_buf[len++] = (char)('0' + (x % 10)); } write_char((char)('0' + x)); while (len) { write_char(num_buf[--len]); } write_char('\n'); } // auto-flush output when program exits void init_output() { assert(atexit(flush_out) == 0); } } // namespace Output //---------------------------------------------------- void solve() { int n; // n = read_int(); cin >> n; vector<pair<int, int>> v(n); int answer = 0; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; v[i] = {a, b}; } for (int i = 0; i < n; i++) { int a = v[i].first, b = v[i].second; if (b == 1) answer++; else { bool f = 0; if (i) f |= (v[i - 1].second == 1); if (i + 1 < n) f |= (v[i + 1].second == 1); if (!f) answer++; } } cout << answer; // write_int(answer); } //---------------------------------------------------- int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // init_output(); solve(); return 0; } //----------------------------------------------------

Compilation message (stderr)

lightningrod.cpp: In function 'void solve()':
lightningrod.cpp:120:13: warning: unused variable 'a' [-Wunused-variable]
  120 |         int a = v[i].first, b = v[i].second;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...