Submission #336512

# Submission time Handle Problem Language Result Execution time Memory
336512 2020-12-15T13:42:16 Z mehrdad_sohrabi Airline Route Map (JOI18_airline) C++14
0 / 100
720 ms 37488 KB
#include <bits/stdc++.h>
#include "Alicelib.h"
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define endl '\n'
//#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
void Alice( int n,int m,int A[],int B[]){
    vector <int> ras;
    for (int i=n;i<n+12;i++){
        ras.pb(i);
    }
    vector <pii> mm;
    for (int i=0;i<m;i++){
        mm.pb({A[i],B[i]});
    }
    for (int i=n+1;i<n+11;i++){
        mm.pb({n,i});
        mm.pb({i,n+11});
    }
    for (int i=n+2;i<n+11;i++){
        mm.pb({i,i-1});
    }
    for (int i=0;i<n;i++){
        mm.pb({i,n+11});
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<10;j++){
            if ((i & (1<<j))){
                mm.pb({i,n+1+j});
            }
        }
    }
    
    InitG(n+12,mm.size());
    for (int i=0;i<mm.size();i++){
        MakeG(i, mm[i].F, mm[i].S);
    }
    /*
    cout << n+12 << " " << mm.size() << endl;
    for (int i=0;i<mm.size();i++){
        cout << mm[i].F << " ";
    }
    cout << endl;
    for (int i=0;i<mm.size();i++){
        cout << mm[i].S << " ";
    }
    */
}
/*
int a[100],b[100];
int32_t main(){
    int n,m;
    cin >> n >> m;
    for (int i=0;i<m;i++){
        cin >> a[i] >> b[i];
    }
    Alice(n,m,a,b);
}
*/
#include <bits/stdc++.h>
#include "Boblib.h"
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
//#define endl '\n'
//#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
void Bob(int V,int U,int C[],int D[]){
    ll id=0,mx=0;
    vector <int> g[V];
    for (int i=0;i<U;i++){
        g[C[i]].pb(D[i]);
        g[D[i]].pb(C[i]);
    }
    for (int i=0;i<V;i++){
        if (g[i].size()>mx){
            mx=g[i].size();
            id=i;
        }
    }
    for (int i=0;i<V;i++){
        if (i!=id && g[i].size()==mx) cout << 1/0;
    }
    ll w=0;
    ll vis[V];
    memset(vis,0,sizeof vis);
    ll bad[V];
    memset(bad,0,sizeof bad);
    for (auto u : g[id]){
        vis[u]=1;
    }
    for (int i=0;i<V-1;i++){
        if (vis[i]==0) w=i;
    }
    bad[w]=2;
    bad[id]=2;
   // cout << id << " rvr " << w << endl;
    vector <pii> ras;
    for (auto u : g[w]){
        ras.pb({g[u].size(),u});
        bad[u]=1;
    }
    sort(ras.begin(),ras.end());
    vector <int> bit;
   // bit.pb(ras[0].S);
    queue <int> q;
    q.push(ras[0].S);
    if (ras.size()>1 && g[ras[0].S].size()==g[ras[1].S].size()) cout << 1/0;
    while(q.size()){
        ll v=q.front();
        if (q.size()>2) cout << 1/0;
        bad[v]=2;
        q.pop();
        bit.pb(v);
        for (auto u : g[v]){
            if (bad[u]==1){
                q.push(u);
            }
        }
    }
    reverse(bit.begin(),bit.end());
    ll val[V];
    memset(val,0,sizeof val);
    for (int i=0;i<bit.size();i++){
        ll v=bit[i];
        for (auto u : g[v]){
            if (bad[u]) continue;
            val[u]+=(1<<i);
        }
    }
    vector <pii> m;
    for (int i=0;i<V;i++){
        if (bad[i]) continue;
        for (auto u : g[i]){
            if (bad[u] || val[u]>val[i]) continue;
            m.pb({val[u],val[i]});
        }
    }
   // for (auto u : m){
     //   cout << u.F << " " << u.S << endl;
   // }
    //for (int i=0;i<V;i++){
      //  cout << val[i] << " fejf " << bad[i] << endl;
    //}
    //for (auto u : bit){
      //  cout << u << endl;
    //}

    InitMap(V-12,m.size());
    for (auto u : m){
        MakeMap(u.F,u.S);
    }
}
/*
int a[100];
int b[100];
int32_t main(){
    int n,m;
    cin >> n >> m;
    for (int i=0;i<m;i++){
        cin >> a[i];
    }
    for (int i=0;i<m;i++){
        cin >> b[i];
    }
    Bob(n,m,a,b);
}
*/

Compilation message

Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i=0;i<mm.size();i++){
      |                  ~^~~~~~~~~~

Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:23:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   23 |         if (g[i].size()>mx){
      |             ~~~~~~~~~~~^~~
Bob.cpp:29:33: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   29 |         if (i!=id && g[i].size()==mx) cout << 1/0;
      |                      ~~~~~~~~~~~^~~~
Bob.cpp:29:48: warning: division by zero [-Wdiv-by-zero]
   29 |         if (i!=id && g[i].size()==mx) cout << 1/0;
      |                                               ~^~
Bob.cpp:55:74: warning: division by zero [-Wdiv-by-zero]
   55 |     if (ras.size()>1 && g[ras[0].S].size()==g[ras[1].S].size()) cout << 1/0;
      |                                                                         ~^~
Bob.cpp:58:34: warning: division by zero [-Wdiv-by-zero]
   58 |         if (q.size()>2) cout << 1/0;
      |                                 ~^~
Bob.cpp:71:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     for (int i=0;i<bit.size();i++){
      |                  ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4920 KB Output is correct
2 Runtime error 7 ms 5992 KB Execution killed with signal 8 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4920 KB Output is correct
2 Runtime error 7 ms 5992 KB Execution killed with signal 8 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 720 ms 37488 KB Output is correct : V - N = 12
2 Correct 574 ms 33216 KB Output is correct : V - N = 12
3 Correct 215 ms 18256 KB Output is correct : V - N = 12
4 Runtime error 13 ms 7084 KB Execution killed with signal 8 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -