Submission #610556

# Submission time Handle Problem Language Result Execution time Memory
610556 2022-07-28T10:10:35 Z 1bin Garbage (POI11_smi) C++14
10 / 100
819 ms 137964 KB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 1e6 + 5;
int n, m, a, b, s, t, w[NMAX], chk[NMAX];
vector<pair<int, int>> adj[NMAX];
vector<vector<int>> v;

void dfs(int x, vector<int> & t){
    t.emplace_back(x);
    for(auto& i = w[x]; i < adj[x].size(); i++){
        auto& [nx, e] = adj[x][i];
        if(chk[e]) continue;
        chk[e] = 1;
        dfs(nx, t);
    }
    return;
}

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a >> b >> s >> t;
        if(s ^ t) {
            adj[a].emplace_back(b, i);
            adj[b].emplace_back(a, i);
        }
    } 
    
    for(int i = 1; i <= n; i++)
        if(adj[i].size() & 1){
             cout << "NIE"; return 0;
        }
    for(int i = 1; i <= n; i++)
        if(w[i] < adj[i].size()){
            vector<int> t;
            dfs(i, t);
            v.emplace_back(t);
        }
        
    cout << v.size() << '\n';
    for(auto& t : v){
        cout << t.size()- 1 << ' ';
        for(int x : t) cout << x << ' ';
        cout << '\n';
    }
    return 0;
}

Compilation message

smi.cpp: In function 'void dfs(int, std::vector<int>&)':
smi.cpp:14:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(auto& i = w[x]; i < adj[x].size(); i++){
      |                         ~~^~~~~~~~~~~~~~~
smi.cpp:15:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   15 |         auto& [nx, e] = adj[x][i];
      |               ^
smi.cpp: In function 'int main()':
smi.cpp:40:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if(w[i] < adj[i].size()){
      |            ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 23764 KB cykl nie jest prosty
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 23892 KB Integer 1263 violates the range [0, 500]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 24276 KB Integer 4216 violates the range [0, 1200]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 24208 KB Integer 3405 violates the range [0, 200]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 24980 KB Integer 9921 violates the range [0, 2000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 36620 KB Integer 104922 violates the range [0, 10000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 399 ms 86172 KB Integer 525044 violates the range [0, 50000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 715 ms 117860 KB Integer 787521 violates the range [0, 75000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 819 ms 137964 KB Integer 950048 violates the range [0, 100000]
2 Halted 0 ms 0 KB -