Submission #291173

# Submission time Handle Problem Language Result Execution time Memory
291173 2020-09-04T20:06:43 Z Dremix10 Split the Attractions (IOI19_split) C++17
18 / 100
120 ms 15096 KB
#include "split.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
    #define pp(x) cerr<<#x<<" = ("<<x.F<<" , "<<x.S<<")"<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
    #define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
    #define p(x)
    #define p2(x,y)
    #define pp(x)
    #define pv(x)
    #define ppv(x)
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int maxp = 22;
const ld EPS = 1e-18;
const ll INF = 1e18;
const int MOD = 1e9+7;
const int N = 2e5+1;

vector<vector<int> > adj(N);
vector<int> res;
bool v[N];
int siz[3];
int curr,cnt;

void dfs(int s){
    cnt++;
    if(cnt==siz[curr-1]+1){
        curr++;
        cnt = 1;
    }
    v[s] = 1;
    res[s] = curr;
    for(auto x : adj[s])
        if(!v[x])
        dfs(x);
}

vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
    siz[0] = a;
    siz[1] = b;
    siz[2] = c;
	int i;
	for(i=0;i<p.size();i++){
        int x = p[i],y = q[i];
        adj[x].push_back(y);
        adj[y].push_back(x);
	}
	res.assign(n,0);
	int start = 0;
    for(i=0;i<n;i++)
        if(adj[i].size()==1)start = i;
    curr = 1;
    cnt = 0;
    dfs(start);
    return res;
}

Compilation message

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:57:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(i=0;i<p.size();i++){
      |          ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB ok, correct split
2 Correct 5 ms 4992 KB ok, correct split
3 Correct 3 ms 4992 KB ok, correct split
4 Correct 4 ms 4992 KB ok, correct split
5 Correct 4 ms 4992 KB ok, correct split
6 Correct 4 ms 4992 KB ok, correct split
7 Correct 106 ms 14840 KB ok, correct split
8 Correct 96 ms 14840 KB ok, correct split
9 Correct 98 ms 14840 KB ok, correct split
10 Correct 100 ms 14968 KB ok, correct split
11 Correct 95 ms 14840 KB ok, correct split
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB ok, correct split
2 Correct 3 ms 4992 KB ok, correct split
3 Correct 4 ms 4992 KB ok, correct split
4 Correct 119 ms 14840 KB ok, correct split
5 Correct 89 ms 11896 KB ok, correct split
6 Correct 96 ms 14840 KB ok, correct split
7 Correct 85 ms 14840 KB ok, correct split
8 Correct 120 ms 15096 KB ok, correct split
9 Correct 84 ms 11768 KB ok, correct split
10 Correct 57 ms 11764 KB ok, correct split
11 Correct 78 ms 11760 KB ok, correct split
12 Correct 61 ms 12144 KB ok, correct split
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB ok, correct split
2 Incorrect 97 ms 11896 KB 2 components are not connected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB ok, correct split
2 Incorrect 4 ms 4992 KB 2 components are not connected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB ok, correct split
2 Correct 5 ms 4992 KB ok, correct split
3 Correct 3 ms 4992 KB ok, correct split
4 Correct 4 ms 4992 KB ok, correct split
5 Correct 4 ms 4992 KB ok, correct split
6 Correct 4 ms 4992 KB ok, correct split
7 Correct 106 ms 14840 KB ok, correct split
8 Correct 96 ms 14840 KB ok, correct split
9 Correct 98 ms 14840 KB ok, correct split
10 Correct 100 ms 14968 KB ok, correct split
11 Correct 95 ms 14840 KB ok, correct split
12 Correct 4 ms 4992 KB ok, correct split
13 Correct 3 ms 4992 KB ok, correct split
14 Correct 4 ms 4992 KB ok, correct split
15 Correct 119 ms 14840 KB ok, correct split
16 Correct 89 ms 11896 KB ok, correct split
17 Correct 96 ms 14840 KB ok, correct split
18 Correct 85 ms 14840 KB ok, correct split
19 Correct 120 ms 15096 KB ok, correct split
20 Correct 84 ms 11768 KB ok, correct split
21 Correct 57 ms 11764 KB ok, correct split
22 Correct 78 ms 11760 KB ok, correct split
23 Correct 61 ms 12144 KB ok, correct split
24 Correct 4 ms 4992 KB ok, correct split
25 Incorrect 97 ms 11896 KB 2 components are not connected
26 Halted 0 ms 0 KB -