Submission #144223

# Submission time Handle Problem Language Result Execution time Memory
144223 2019-08-16T10:09:07 Z Abelyan Izlet (COI19_izlet) C++17
18 / 100
621 ms 35920 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa

const int N=3e3+10;
const ll MOD2=998244353;
const ll MOD=1e9+7;

int qan[N][N],par[N];
bool col[N];

int get(int v){
    if (par[v]==v)return v;
    return par[v]=get(par[v]);
}

void unite(int a,int b){
    a=get(a);
    b=get(b);
    if (a!=b){
        if (b>a)swap(a,b);
        par[a]=b;
    }
}

int main(){
    fastio;
    srng;
    int tp;
    cin>>tp;
    if (tp==1){
        int n;
        cin>>n;
        FORT(i,1,n)par[i]=i;
        FORT(i,1,n){
            FORT(j,1,n){
                cin>>qan[i][j];
                if (qan[i][j]==1)unite(i,j);
            }
        }
        FORT(i,1,n){
            if (get(i)==1)cout<<1<<" ";
            else cout<<2<<" ";
        }
        cout<<endl;
        FORT(i,1,n){
            if (i!=get(i))
                cout<<i<<" "<<get(i)<<endl;
        }
        FORT(i,2,n){
            int k=get(i);
            if (k==1 || col[k])continue;
            col[k]=true;
            cout<<1<<" "<<k<<endl;
        }
    }
    return 0;
}
/*
7 2 8
C 1
C 2
C 3
C 4
C 5
C 6
O 7
O 7

*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 605 ms 35804 KB Output is correct
3 Correct 609 ms 35764 KB Output is correct
4 Correct 621 ms 35920 KB Output is correct
5 Correct 610 ms 35832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 605 ms 35804 KB Output is correct
3 Correct 609 ms 35764 KB Output is correct
4 Correct 621 ms 35920 KB Output is correct
5 Correct 610 ms 35832 KB Output is correct
6 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
7 Halted 0 ms 0 KB -