Submission #1021708

# Submission time Handle Problem Language Result Execution time Memory
1021708 2024-07-13T03:02:51 Z lHog Monthly railway pass (LMIO18_menesinis_bilietas) C++17
0 / 100
3000 ms 26456 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> veci;
typedef vector<ll> vecll;
#define mp make_pair
#define fi first
#define se second
// debug needs a semicolon !!!
#define debug(x) cerr<<# x<<" is "<<x<<'\n'
#define vec vector

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, m;
    cin >> n >> m;
    veci a[n];
    for (int i=0; i<n; i++) {
        int x;
        cin >> x;
        a[i].push_back(x);
        char USELESS;
        cin >> USELESS;
    }
    queue<int> tv;
    tv.push(0);
    bool visited[n]={1};
    while (!tv.empty()) {
        int x = tv.front();
        tv.pop();
        for (int i=0; i<a[x].size(); i++) {
            if (!visited[a[x][i]]) {
                tv.push(i);
            }
        }
    }
    for (int i=0; i<n; i++) {
        if (!visited[i]) {
            cout << 0;
            return 0;
        }
    }
    cout << n;
	return 0;
}

Compilation message

menesinis_bilietas.cpp: In function 'int main()':
menesinis_bilietas.cpp:35:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for (int i=0; i<a[x].size(); i++) {
      |                       ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 3037 ms 16984 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3035 ms 26456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -