Submission #918244

# Submission time Handle Problem Language Result Execution time Memory
918244 2024-01-29T13:46:43 Z devkudawla Lightning Rod (NOI18_lightningrod) C++17
4 / 100
226 ms 188756 KB
#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();
    vector<pair<int, int>> v(n);
    int answer = 0;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        a = read_int();
        b = read_int();
        if (b == 1)
            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

lightningrod.cpp: In function 'void solve()':
lightningrod.cpp:113:13: warning: variable 'a' set but not used [-Wunused-but-set-variable]
  113 |         int a, b;
      |             ^
# Verdict Execution time Memory Grader output
1 Correct 226 ms 188756 KB Output is correct
2 Correct 213 ms 188424 KB Output is correct
3 Correct 205 ms 183288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 153 ms 78424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 226 ms 188756 KB Output is correct
2 Correct 213 ms 188424 KB Output is correct
3 Correct 205 ms 183288 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -