Submission #1733913


Source Code Expand

Copy
#include<bits/stdc++.h>

using namespace std;


using int64 = long long;

struct edge
{
  int to, cost;
};

int N, M;
vector< edge > g[300];
bool v[300];
int pre[300];
int gg[300][300];

void createLoop(int a, int b)
{
  vector< int > vs;
  vs.push_back(a);
  while(pre[a] != b) {
    vs.emplace_back(b);
    a = pre[a];
  }
  vs.push_back(b);
  reverse(begin(vs), end(vs));

}
void dfs(int idx)
{
  v[idx] = true;
  for(auto &e : g[idx]) {
    if(v[e.to]) {
      createLoop(idx, e.to);
    } else {
      pre[e.to] = idx;
      dfs(e.to);
    }
  }
}

int main()
{
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    g[a].emplace_back((edge) {b, c});
    gg[a][b]  = true;
  }

  dfs(0);
}

Submission Info

Submission Time
Task C - グラフいじり
User ei13333
Language C++14 (GCC 5.4.1)
Score 0
Code Size 801 Byte
Status
Exec Time 2108 ms
Memory 1287760 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 example_0, example_1, example_2
All 0 / 800 divide2_0, divide2_1, divide2_10, divide2_11, divide2_12, divide2_13, divide2_14, divide2_15, divide2_16, divide2_17, divide2_18, divide2_19, divide2_2, divide2_3, divide2_4, divide2_5, divide2_6, divide2_7, divide2_8, divide2_9, example_0, example_1, example_2, manyerr_0, manyerr_1, manyerr_10, manyerr_11, manyerr_12, manyerr_13, manyerr_14, manyerr_15, manyerr_16, manyerr_17, manyerr_18, manyerr_19, manyerr_2, manyerr_3, manyerr_4, manyerr_5, manyerr_6, manyerr_7, manyerr_8, manyerr_9, rand_0, rand_1, rand_10, rand_11, rand_12, rand_13, rand_14, rand_15, rand_16, rand_17, rand_18, rand_19, rand_2, rand_3, rand_4, rand_5, rand_6, rand_7, rand_8, rand_9, small_0, small_1, small_10, small_11, small_12, small_13, small_14, small_15, small_16, small_17, small_18, small_19, small_2, small_3, small_4, small_5, small_6, small_7, small_8, small_9
Case Name Status Exec Time Memory
divide2_0 2107 ms 1240396 KB
divide2_1 2107 ms 1267156 KB
divide2_10 2107 ms 1213648 KB
divide2_11 2107 ms 1276244 KB
divide2_12 2107 ms 1239372 KB
divide2_13 2108 ms 1279184 KB
divide2_14 2107 ms 1226572 KB
divide2_15 2108 ms 1282256 KB
divide2_16 2107 ms 1242700 KB
divide2_17 2108 ms 1283128 KB
divide2_18 2108 ms 1233228 KB
divide2_19 2107 ms 1281104 KB
divide2_2 2108 ms 1197260 KB
divide2_3 2108 ms 1259560 KB
divide2_4 2108 ms 1236556 KB
divide2_5 2108 ms 1280336 KB
divide2_6 2107 ms 1238476 KB
divide2_7 2108 ms 1282404 KB
divide2_8 2108 ms 1237196 KB
divide2_9 2107 ms 1256908 KB
example_0 1 ms 256 KB
example_1 1 ms 256 KB
example_2 1 ms 256 KB
manyerr_0 2107 ms 1174476 KB
manyerr_1 2107 ms 1202004 KB
manyerr_10 2107 ms 1188300 KB
manyerr_11 2107 ms 1229004 KB
manyerr_12 2108 ms 1185868 KB
manyerr_13 2108 ms 1285076 KB
manyerr_14 2107 ms 1182396 KB
manyerr_15 2108 ms 1287124 KB
manyerr_16 2107 ms 1182924 KB
manyerr_17 2108 ms 1285332 KB
manyerr_18 2107 ms 1180652 KB
manyerr_19 2108 ms 1272280 KB
manyerr_2 2107 ms 1179468 KB
manyerr_3 2107 ms 1273824 KB
manyerr_4 2107 ms 1181500 KB
manyerr_5 2107 ms 1216980 KB
manyerr_6 2107 ms 1182924 KB
manyerr_7 2107 ms 1278540 KB
manyerr_8 2107 ms 1173984 KB
manyerr_9 2107 ms 1268812 KB
rand_0 2107 ms 1183948 KB
rand_1 2108 ms 1271504 KB
rand_10 2107 ms 1185668 KB
rand_11 2108 ms 1282644 KB
rand_12 2107 ms 1185612 KB
rand_13 2107 ms 1246156 KB
rand_14 2107 ms 1184992 KB
rand_15 2107 ms 1266892 KB
rand_16 2107 ms 1165132 KB
rand_17 2107 ms 1272660 KB
rand_18 2107 ms 1175680 KB
rand_19 2107 ms 1268428 KB
rand_2 2107 ms 1164876 KB
rand_3 2107 ms 1281616 KB
rand_4 2107 ms 1184520 KB
rand_5 2108 ms 1270992 KB
rand_6 2108 ms 1183564 KB
rand_7 2107 ms 1245012 KB
rand_8 2108 ms 1188008 KB
rand_9 2108 ms 1274708 KB
small_0 2107 ms 1277520 KB
small_1 2107 ms 1284560 KB
small_10 2108 ms 1277232 KB
small_11 2108 ms 1283152 KB
small_12 2107 ms 1280972 KB
small_13 2108 ms 1281744 KB
small_14 2108 ms 1286708 KB
small_15 2108 ms 1284688 KB
small_16 2108 ms 1285072 KB
small_17 2108 ms 1284048 KB
small_18 2107 ms 1282708 KB
small_19 2108 ms 1287760 KB
small_2 1 ms 256 KB
small_3 2107 ms 1285200 KB
small_4 2107 ms 1284816 KB
small_5 2107 ms 1283280 KB
small_6 2107 ms 1285456 KB
small_7 2108 ms 1283920 KB
small_8 2108 ms 1285584 KB
small_9 2108 ms 1286224 KB