Submission #388817

# Submission time Handle Problem Language Result Execution time Memory
388817 2021-04-13T04:57:39 Z armashka Izlet (COI19_izlet) C++17
0 / 100
568 ms 89676 KB
#include <bits/stdc++.h>
#include <math.h>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ll long long
#define pb push_back
#define pf push_front
#define sz(x) x.size()
#define mp make_pair
#define F first
#define S second
#define ins insert
#define all(v) v.begin(),v.end()
#define left(v) v << 1
#define right(v) (v << 1) + 1
#define pii pair<int, int>
#define pll pair<ll, ll>
#define file(a) freopen(a".in", "r", stdin);freopen(a".out", "w", stdout);
#define show(x) cerr << #x <<" -> "<< x <<" "
#define nl cerr << "\n"

using namespace std;

const ll N = 3e5;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

void Speed() {  
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

int T = 1;
ll n, m, a[3012][3012], p[3012], col[3012];
vector <ll> g[3012];
map <ll, ll> m1[3012];

void solve() {
    cin >> m >> n;
    for (int i = 1; i <= n; ++ i)
        for (int j = 1; j <= n; ++ j) cin >> a[i][j];

    col[1] = 1; p[1] = -1;
    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j <= n; ++ j) {
            if (a[i][j] == 2 && !m1[i][j] && (!p[i] || i == 1)) {
                g[i].pb(j); g[j].pb(i); 
                ++ m1[i][j]; ++ m1[j][i];
                col[j] = col[i] + 1; p[j] = i;
            }
        }
    }
    for (int i = 1; i <= n; ++ i) cout << col[i] << " ", m1[i].clear();
    cout << "\n";
    for (int i = 1; i <= n; ++ i) {
        for (int j = 0; j < sz(g[i]); ++ j) {
            ll to = g[i][j];
            if (!m1[i][to]) {cout << i << " " << to << "\n"; ++ m1[i][to]; ++ m1[to][i];}
        }
    }
}

int main () {
    // file("B");
    Speed();
//    cin >> T;
    while (T --) solve();
    return 0;
}

/*
3 5
1 1 3 100
0 1 2 10
2 1 3 100
1 2 3 4
0 1 3 10

5 5
0 1 5 1000000007
1 2 3 6
0 1 5 1000000007
2 2 3 3
0 1 5 1000000007

*/

Compilation message

izlet.cpp:4: warning: ignoring #pragma comment  [-Wunknown-pragmas]
    4 | #pragma comment(linker, "/stack:200000000")
      | 
izlet.cpp: In function 'void solve()':
izlet.cpp:59:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         for (int j = 0; j < sz(g[i]); ++ j) {
      |                           ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 716 KB Integer 0 violates the range [1, 30]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 568 ms 89676 KB Integer 0 violates the range [1, 3000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 716 KB Integer 0 violates the range [1, 30]
2 Halted 0 ms 0 KB -