Submission #1194995


Source Code Expand

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1.01e9;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int mod = (int) 1e9 + 7;

void add(int & x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int sum(int x, int y) {
  add(x, y);
  return x;
}

int mult(int x, int y) {
  return (ll) x * y % mod;
}

int power(int x, ll p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
    p >>= 1;
  }
  return res;
}

int inv(int x) {
  return power(x, mod - 2);
}

void precalc() {
}

const int maxn = 1e5 + 100;
const int maxd = 12;

int n, m, q;
vector<vector<int> > g;
int v[maxn], d[maxn], c[maxn];

bool read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  g.clear();
  g.resize(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    g[a].pb(b);
    g[b].pb(a);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d", v + i, d + i, c + i);
    v[i]--;
  }
  return true;
}

int used[maxn][maxd];

int cols[maxn];

void solve() {
  reverse(v, v + q);
  reverse(d, d + q);
  reverse(c, c + q);
  memset(used, 0, sizeof(used));
  memset(cols, 0, sizeof(cols));
  for (int i = 0; i < q; i++) {
    vector<pair<int, int> > st(1, mp(v[i], d[i]));
    for (int l = 0; l < sz(st); l++) {
      int curv = st[l].first;
      int curd = st[l].second;
      if (used[curv][curd]) {
        continue;
      }
      if (!used[curv][0]) {
        cols[curv] = c[i];
      }
      for (int j = 0; j <= curd; j++) {
        used[curv][j] = 1;
      }
      if (!curd) {
        continue;
      }
      for (auto to : g[curv]) {
        st.pb(mp(to, curd - 1));
      }
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d\n", cols[i]);
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.3f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Submission Info

Submission Time
Task B - Splatter Painting
User StanislavErshov
Language C++14 (GCC 5.4.1)
Score 700
Code Size 2567 Byte
Status AC
Exec Time 103 ms
Memory 16028 KB

Compile Error

./Main.cpp: In function ‘bool read()’:
./Main.cpp:82:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &a, &b);
                          ^
./Main.cpp:87:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q);
                  ^
./Main.cpp:89:41: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", v + i, d + i, c + i);
                                         ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 500 / 500
Status
AC × 2
AC × 19
AC × 35
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
Subtask1 00_example_01.txt, 00_example_02.txt, 10_01.txt, 10_02.txt, 10_03.txt, 10_04.txt, 10_05.txt, 10_06.txt, 10_07.txt, 10_08.txt, 10_09.txt, 10_10.txt, 10_11.txt, 10_12.txt, 10_13.txt, 10_14.txt, 10_15.txt, 10_16.txt, 10_17.txt
All 00_example_01.txt, 00_example_02.txt, 10_01.txt, 10_02.txt, 10_03.txt, 10_04.txt, 10_05.txt, 10_06.txt, 10_07.txt, 10_08.txt, 10_09.txt, 10_10.txt, 10_11.txt, 10_12.txt, 10_13.txt, 10_14.txt, 10_15.txt, 10_16.txt, 10_17.txt, 20_01.txt, 20_02.txt, 20_03.txt, 20_04.txt, 20_05.txt, 20_06.txt, 20_07.txt, 20_08.txt, 20_09.txt, 20_10.txt, 20_11.txt, 20_12.txt, 20_13.txt, 20_14.txt, 20_15.txt, 20_16.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 3 ms 6400 KB
00_example_02.txt AC 3 ms 6400 KB
10_01.txt AC 3 ms 6400 KB
10_02.txt AC 3 ms 6400 KB
10_03.txt AC 3 ms 6400 KB
10_04.txt AC 3 ms 6400 KB
10_05.txt AC 3 ms 6400 KB
10_06.txt AC 3 ms 6400 KB
10_07.txt AC 3 ms 6400 KB
10_08.txt AC 5 ms 6528 KB
10_09.txt AC 5 ms 6528 KB
10_10.txt AC 5 ms 6528 KB
10_11.txt AC 5 ms 6528 KB
10_12.txt AC 5 ms 6528 KB
10_13.txt AC 4 ms 6528 KB
10_14.txt AC 4 ms 6528 KB
10_15.txt AC 4 ms 6528 KB
10_16.txt AC 4 ms 6528 KB
10_17.txt AC 4 ms 6528 KB
20_01.txt AC 100 ms 12160 KB
20_02.txt AC 103 ms 12192 KB
20_03.txt AC 100 ms 12160 KB
20_04.txt AC 19 ms 8804 KB
20_05.txt AC 5 ms 6400 KB
20_06.txt AC 12 ms 8832 KB
20_07.txt AC 5 ms 6400 KB
20_08.txt AC 21 ms 6784 KB
20_09.txt AC 5 ms 6400 KB
20_10.txt AC 20 ms 6400 KB
20_11.txt AC 27 ms 6912 KB
20_12.txt AC 53 ms 11648 KB
20_13.txt AC 86 ms 12032 KB
20_14.txt AC 89 ms 11904 KB
20_15.txt AC 77 ms 15956 KB
20_16.txt AC 82 ms 16028 KB