Submission #465237

# Submission time Handle Problem Language Result Execution time Memory
465237 2021-08-15T12:15:49 Z mario05092929 Teleporters (IOI08_teleporters) C++11
10 / 100
434 ms 35900 KB
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast") 
#pragma gcc optimize("unroll-loops")
using namespace std;
const int INF = 1e9;
const int TMX = 1 << 18;
const long long llINF = 1e16;
const long long mod = 1e9+7;
const long long hashmod = 100003;
const int MAXN = 100000;
const int MAXM = 1000000;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
typedef vector <pi> vecpi;
typedef long long ll;
int c[4000005],ans;
int n,k,End = 4000002;
int p[4000005];

int go(int x,int po) {
    if(c[x]&&!p[x]) return 0;
    c[x] = 1;
    if(p[x]&&!po) return go(p[x],1)+1;
    return go(x+1,0);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    for(int i = 1;i <= n;i++) {
        int x,y; cin >> x >> y;
        x *= 2, y *= 2;
        p[x] = y, p[y] = x;
    }
    ans = go(0,0);
    vec v;
    c[End] = 1;
    for(int i = 1;i <= End;i++) if(!c[i]) v.pb(go(i,0));
    sort(all(v));
    reverse(all(v));
    for(int i = 0;i < v.size()&&i < k;i++) ans += v[i]+2;
    k -= min((int)v.size(),k);
    cout << ans+(k/2)*4+k%2;
}

Compilation message

teleporters.cpp:6: warning: ignoring '#pragma gcc optimize' [-Wunknown-pragmas]
    6 | #pragma gcc optimize("O3")
      | 
teleporters.cpp:7: warning: ignoring '#pragma gcc optimize' [-Wunknown-pragmas]
    7 | #pragma gcc optimize("Ofast")
      | 
teleporters.cpp:8: warning: ignoring '#pragma gcc optimize' [-Wunknown-pragmas]
    8 | #pragma gcc optimize("unroll-loops")
      | 
teleporters.cpp: In function 'int main()':
teleporters.cpp:49:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i = 0;i < v.size()&&i < k;i++) ans += v[i]+2;
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 15948 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 15976 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 15904 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 15960 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 15948 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 15940 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 15948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 15948 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 15948 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 15900 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 16080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 16076 KB Output is correct
2 Incorrect 28 ms 16380 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 16168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 16160 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 16260 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 20196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 107 ms 26272 KB Output is correct
2 Incorrect 222 ms 32248 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 273 ms 33752 KB Output is correct
2 Incorrect 327 ms 33900 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 394 ms 33756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 404 ms 35784 KB Output is correct
2 Incorrect 434 ms 35900 KB Output isn't correct
3 Halted 0 ms 0 KB -