Submission #1074171

# Submission time Handle Problem Language Result Execution time Memory
1074171 2024-08-25T08:33:06 Z Malix Tropical Garden (IOI11_garden) C++14
49 / 100
145 ms 262144 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;

#define REP(a,b,c) for(int a=b;a<c;a++)
#define F first
#define S second
#define PB push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;

vii a,b,c;
int k=0;

void solve(int x){
  REP(i,1,k){
    int p=b[x][i-1];
    int q=b[x][i];
    if(a[q].size()==1){
      b[x][i+1]=a[q][0];
      continue;
    }
    if(a[q].front()==p){
      b[x][i+1]=a[q][1];
      continue;
    }
    else{
      b[x][i+1]=a[q][0];
      continue;
    }
  }
}

void count_routes(int n, int m, int P, int R[][2], int Q, int G[])
{
  a.resize(n);
  REP(i,0,m){
    int x=R[i][0];
    int y=R[i][1];
    a[x].PB(y);
    a[y].PB(x);
  }
  b.resize(n,vi(G[0]+1));
  k=G[0];
  REP(i,0,n){
    b[i][0]=i;
    b[i][1]=a[i].front();
  }
  REP(i,0,n)solve(i);
  int ans=0;
  REP(i,0,n)if(b[i][G[0]]==P)ans++;
  answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 864 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 860 KB Output is correct
9 Correct 4 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 864 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 860 KB Output is correct
9 Correct 4 ms 1116 KB Output is correct
10 Correct 10 ms 4188 KB Output is correct
11 Runtime error 145 ms 262144 KB Execution killed with signal 9
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 864 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 860 KB Output is correct
9 Correct 4 ms 1116 KB Output is correct
10 Correct 10 ms 4188 KB Output is correct
11 Runtime error 145 ms 262144 KB Execution killed with signal 9
12 Halted 0 ms 0 KB -