답안 #395410

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
395410 2021-04-28T10:34:19 Z MarcoMeijer Regions (IOI09_regions) C++14
0 / 100
85 ms 131076 KB
#include <bits/stdc++.h>
using namespace std;
 
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e18
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
// input
template<class T> void IN(T& x) {cin >> x;}
template<class H, class... T> void IN(H& h, T&... t) {IN(h); IN(t...); }
 
// output
template<class T1, class T2> void OUT(const pair<T1,T2>& x);
template<class T> void OUT(const vector<T>& x);
template<class T> void OUT(const T& x) {cout << x;}
template<class H, class... T> void OUT(const H& h, const T&... t) {OUT(h); OUT(t...); }
template<class T1, class T2> void OUT(const pair<T1,T2>& x) {OUT(x.fi,' ',x.se);}
template<class T> void OUT(const vector<T>& x) {RE(i,x.size()) OUT(i==0?"":" ",x[i]);}
template<class... T> void OUTL(const T&... t) {OUT(t..., "\n"); }
template<class H> void OUTLS(const H& h) {OUTL(h); }
template<class H, class... T> void OUTLS(const H& h, const T&... t) {OUT(h,' '); OUTLS(t...); }
 
// dp
template<class T> bool ckmin(T&a, T&b) { bool bl = a > b; a = min(a,b); return bl;}
template<class T> bool ckmax(T&a, T&b) { bool bl = a < b; a = max(a,b); return bl;}
 
void program();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    program();
}
 
 
//===================//
//   begin program   //
//===================//
 
const int MX = 2e5+10;
const int SQ = 502;
const int N = (1<<20);

int n, r, q;
int h[MX], p[MX];
vi chl[MX];
int ways[SQ][SQ];
int tot[MX][SQ];

void program() {
    // input
    IN(n,r,q);
    RE1(i,n) {
        if(i != 1) {
            IN(p[i]);
            chl[p[i]].pb(i);
        } else p[i] = -1;
        IN(h[i]);
    }
    if(r >= SQ) return;

    // fill tot
    memset(tot,0,sizeof(tot));
    RE1(i,n) tot[i][h[i]] = 1;
    REV(u,1,n+1) RE1(j,r) FOR(v,chl[u]) tot[u][j] += tot[v][j];

    // fill ways
    memset(ways,0,sizeof(ways));
    RE1(i,n) RE1(j,r) ways[h[i]][j] += tot[i][j];

    // answer queries
    RE(_,q) {
        int r1, r2; IN(r1,r2);
        OUTL(ways[r1][r2]);
        cout.flush();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 69 ms 131076 KB Execution killed with signal 9
2 Runtime error 60 ms 131076 KB Execution killed with signal 9
3 Runtime error 67 ms 131076 KB Execution killed with signal 9
4 Runtime error 64 ms 131076 KB Execution killed with signal 9
5 Runtime error 76 ms 131076 KB Execution killed with signal 9
6 Runtime error 66 ms 131076 KB Execution killed with signal 9
7 Runtime error 70 ms 131076 KB Execution killed with signal 9
8 Runtime error 62 ms 131076 KB Execution killed with signal 9
9 Runtime error 63 ms 131076 KB Execution killed with signal 9
10 Runtime error 75 ms 131076 KB Execution killed with signal 9
11 Runtime error 72 ms 131076 KB Execution killed with signal 9
12 Runtime error 65 ms 131076 KB Execution killed with signal 9
13 Runtime error 67 ms 131076 KB Execution killed with signal 9
14 Runtime error 65 ms 131076 KB Execution killed with signal 9
15 Runtime error 71 ms 131076 KB Execution killed with signal 9
# 결과 실행 시간 메모리 Grader output
1 Runtime error 83 ms 131076 KB Execution killed with signal 9
2 Runtime error 84 ms 131076 KB Execution killed with signal 9
3 Runtime error 85 ms 131076 KB Execution killed with signal 9
4 Incorrect 11 ms 5944 KB Unexpected end of file - int32 expected
5 Incorrect 12 ms 6344 KB Unexpected end of file - int32 expected
6 Incorrect 20 ms 6708 KB Unexpected end of file - int32 expected
7 Incorrect 25 ms 7288 KB Unexpected end of file - int32 expected
8 Incorrect 30 ms 8928 KB Unexpected end of file - int32 expected
9 Incorrect 47 ms 10424 KB Unexpected end of file - int32 expected
10 Incorrect 47 ms 11596 KB Unexpected end of file - int32 expected
11 Incorrect 57 ms 10048 KB Unexpected end of file - int32 expected
12 Incorrect 52 ms 12224 KB Unexpected end of file - int32 expected
13 Incorrect 53 ms 11720 KB Unexpected end of file - int32 expected
14 Incorrect 55 ms 11672 KB Unexpected end of file - int32 expected
15 Incorrect 59 ms 12684 KB Unexpected end of file - int32 expected
16 Incorrect 68 ms 12740 KB Unexpected end of file - int32 expected
17 Incorrect 59 ms 12724 KB Unexpected end of file - int32 expected