Submission #1064398

# Submission time Handle Problem Language Result Execution time Memory
1064398 2024-08-18T12:13:00 Z crafticat Inside information (BOI21_servers) C++17
2.5 / 100
203 ms 299620 KB
#include <bits/stdc++.h>

using namespace std;

#include <bits/stdc++.h>

#include <utility>
using namespace std;

using ll = long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;

#define temp(T) template<class T>
temp(T) using V = vector<T>;
using vi = V<int>;
using vl = V<ll>;
using vvi = V<vi>;
using vpi = V<pi>;
using vb = V<bool>;
using vvb = V<vb>;
vi dx = {0,1,-1,0};
vi dy = {1,0,0,-1};

#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define pb push_back
#define eb emplace_back
#define f first
#define s second

#define lb lower_bound
#define ub upper_bound

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rep(a) F0R(_,a)
#define each(a,x) for (auto& a: x)

using str = string;

const int MOD = 1e9 + 7;
const ll BIG = 1e18;
const int INF = 1e9 + 2;

temp(T) bool ckmin(T& a, const T& b) {
    return b < a ? a = b, 1 : 0; } // set a = min(a,b)
temp(T) bool ckmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0; } // set a = max(a,b)

void unsyncIO() { cin.tie(0)->sync_with_stdio(0); }
// FILE I/O
void setIn(str s) { freopen(s.c_str(),"r",stdin); }
void setOut(str s) { freopen(s.c_str(),"w",stdout); }
void setIO(str s = "") {
    unsyncIO();
    if (sz(s)) setIn(s+".in"), setOut(s+".out"); // for USACO
}

#define read(x) int x; cin >> x

temp(T) void pr(T x) {
    cout << to_string(x);
}
temp(T) void prln(T x) {
    cout << to_string(x) << "\n";
}


vi readV(int n) {

    vi input(n);
    F0R(i,n)
        cin >> input[i];
    return input;
}

int rand(int a, int b) {
    return a + rand() % (b - a + 1);
}

#define gen(x,a,b) int x = rand(a,b)

temp(T) void moveAll(V<T> &a, V<T> &b) {
    each(x,b) {
        a.pb(x);
    }
    b.clear();
}

vi genArr(int n, int a, int b) {
    vi generated(n);
    F0R(i,n) {
        generated[i] = rand(a,b);
    }
    return generated;
}

vvi genTree(int n) {
    vvi g(n + 1);
    F0R(i,n) {
        gen(p,0,i);
        g[p].pb(i + 1);
        g[i + 1].pb(p);
    }

    return g;
}

vvb readGrid(int a, int b) {
    vvb grid(a + 2, vb(b + 2, true));

    F0R(i, a) {
        F0R(j, b) {
            bool k; cin >> k;
            grid[i + 1][j + 1] = k;
        }
    }
    return grid;
}


int main() {
    setIO();
    int n, q; cin >>n >> q;
    V<bitset<10001>> dat(n + 1);
    F0R(i, n + 1)
        dat[i][i] = true;

    F0R(i, q + n - 1) {
        char t; cin >> t;

        if (t == 'S') {
            int a, b; cin >> a >> b;
            dat[a] = dat[b] = dat[a] | dat[b];
        }
        if (t == 'Q') {
            int a, b; cin >> a >> b;
            cout << (dat[a][b] ? "yes" : "no") << "\n";
        }
        if (t == 'C') {
            exit(5);
        }
    }

    return 0;
}

Compilation message

servers.cpp: In function 'void setIn(str)':
servers.cpp:59:28: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 | void setIn(str s) { freopen(s.c_str(),"r",stdin); }
      |                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
servers.cpp: In function 'void setOut(str)':
servers.cpp:60:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 | void setOut(str s) { freopen(s.c_str(),"w",stdout); }
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1628 KB Output is correct
2 Correct 21 ms 6992 KB Output is correct
3 Correct 20 ms 7004 KB Output is correct
4 Correct 21 ms 6988 KB Output is correct
5 Correct 21 ms 7112 KB Output is correct
6 Correct 22 ms 7004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1628 KB Output is correct
2 Correct 21 ms 6992 KB Output is correct
3 Correct 20 ms 7004 KB Output is correct
4 Correct 21 ms 6988 KB Output is correct
5 Correct 21 ms 7112 KB Output is correct
6 Correct 22 ms 7004 KB Output is correct
7 Runtime error 1 ms 604 KB Execution failed because the return code was nonzero
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1656 KB Output is correct
2 Runtime error 180 ms 299524 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1656 KB Output is correct
2 Runtime error 180 ms 299524 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1624 KB Output is correct
2 Runtime error 203 ms 299460 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1624 KB Output is correct
2 Runtime error 203 ms 299460 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1628 KB Output is correct
2 Runtime error 181 ms 299620 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1628 KB Output is correct
2 Runtime error 181 ms 299620 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1624 KB Output is correct
2 Runtime error 176 ms 299424 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1624 KB Output is correct
2 Runtime error 176 ms 299424 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1628 KB Output is correct
2 Correct 25 ms 7004 KB Output is correct
3 Correct 24 ms 7004 KB Output is correct
4 Correct 24 ms 7072 KB Output is correct
5 Correct 24 ms 7112 KB Output is correct
6 Correct 25 ms 7032 KB Output is correct
7 Correct 15 ms 1624 KB Output is correct
8 Runtime error 182 ms 299604 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1628 KB Output is correct
2 Correct 25 ms 7004 KB Output is correct
3 Correct 24 ms 7004 KB Output is correct
4 Correct 24 ms 7072 KB Output is correct
5 Correct 24 ms 7112 KB Output is correct
6 Correct 25 ms 7032 KB Output is correct
7 Correct 15 ms 1624 KB Output is correct
8 Runtime error 182 ms 299604 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -