Submission #1018671

# Submission time Handle Problem Language Result Execution time Memory
1018671 2024-07-10T08:11:35 Z vjudge1 Planinarenje (COCI18_planinarenje) C++17
80 / 160
1000 ms 952 KB
#include<bits/stdc++.h>

using namespace std;

const int N = 5005 * 2;
int n, m;
vector<int> G[N];
bool seen[N];

bool dfs(int v)
{
  seen[v] = true;
  bool dead = true, l = false;
  for(int u : G[v])
    {
      if(seen[u]) continue;
      dead = false;
      bool s = dfs(u);
      // cerr << u << ' ' << s << endl;
      l |= !s;
    }
  seen[v] = false;
  if(dead) return false;
  return l;
}


int main()
{
  cin >> n >> m;
  for(int i = 0; i < m ; i++)
    {
      int u, v;
      cin >> u >> v;
      v += n;
      G[u].push_back(v);
      G[v].push_back(u);
    }

  for(int i = 1; i <= n; i ++)
    {
      cout << (dfs(i) ? "Slavko" : "Mirko") << "\n";
      for(int j = 1; j <= 2 * n; j ++)
	seen[j] = false;
    }
  return 0; 
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 860 KB Output is correct
2 Correct 3 ms 820 KB Output is correct
3 Correct 3 ms 860 KB Output is correct
4 Correct 3 ms 952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1100 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1056 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 848 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1036 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -