Submission #8352554


Source Code Expand

Copy
#include <algorithm>
#include <array>
#include <assert.h>
#include <chrono>
#include <bitset>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <random>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<pll> vpll;

#ifdef OLBOEB
mt19937 rnd(228 + 1488 + 238 + 24111997 % 322);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

void print_time() {
#ifdef OLBOEB
    cout.flush();
    cerr << "\ntime: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(x) ((ll)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }


void no() { cout << "No" << endl; exit(0); }
void yes() { cout << "Yes" << endl; exit(0); }

int main() {
    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n;
    cin >> n;
    vvl x(n, vl(2));
    for (ll i = 0; i < 2; ++i) {
        for (ll j = 0; j < n; ++j) {
            cin >> x[1 - i][j];
        }
    }
    sort(all(x));
    vl a(n);
    vl b(n);
    for (ll i = 0; i < n; ++i) {
        a[i] = x[1][i];
        b[i] = x[0][i];
    }

    vl sa = a;
    sort(all(sa));
    for (ll i = 0; i < n; ++i) {
        if (sa[i] > b[i]) no();
    }

    for (ll i = 0; i + 1 < n; ++i) {
        swap(sa[i], sa[i + 1]);
        if (sa[i] <= b[i] && sa[i + 1] <= b[i + 1]) yes();

        swap(sa[i], sa[i + 1]);
    }

    no();


    print_time();
    return 0;
}

Submission Info

Submission Time
Task C - Swaps
User VadymKa
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2728 Byte
Status RE
Exec Time 159 ms
Memory 7936 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 1
WA × 2
AC × 7
WA × 16
RE × 16
Set Name Test Cases
Sample sample01.txt, sample02.txt, sample03.txt
All sample01.txt, sample02.txt, sample03.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in30.txt, in31.txt, in32.txt, in33.txt, sample01.txt, sample02.txt, sample03.txt
Case Name Status Exec Time Memory
in01.txt AC 36 ms 7680 KB
in02.txt AC 32 ms 7424 KB
in03.txt RE 159 ms 5248 KB
in04.txt RE 130 ms 5504 KB
in05.txt AC 34 ms 7808 KB
in06.txt RE 132 ms 5504 KB
in07.txt RE 132 ms 5760 KB
in08.txt RE 129 ms 5504 KB
in09.txt RE 127 ms 5376 KB
in10.txt RE 132 ms 5504 KB
in11.txt WA 34 ms 7296 KB
in12.txt RE 126 ms 5248 KB
in13.txt WA 32 ms 7424 KB
in14.txt RE 130 ms 5632 KB
in15.txt RE 126 ms 5248 KB
in16.txt WA 35 ms 7552 KB
in17.txt WA 32 ms 7424 KB
in18.txt WA 34 ms 7808 KB
in19.txt RE 127 ms 5248 KB
in20.txt WA 34 ms 7936 KB
in21.txt WA 38 ms 7808 KB
in22.txt RE 132 ms 5632 KB
in23.txt RE 133 ms 5504 KB
in24.txt WA 32 ms 7296 KB
in25.txt RE 129 ms 5376 KB
in26.txt AC 10 ms 2432 KB
in27.txt RE 110 ms 1792 KB
in28.txt RE 112 ms 2432 KB
in29.txt AC 2 ms 384 KB
in30.txt WA 3 ms 640 KB
in31.txt WA 19 ms 4608 KB
in32.txt WA 11 ms 2688 KB
in33.txt WA 15 ms 3712 KB
sample01.txt WA 1 ms 256 KB
sample02.txt AC 1 ms 256 KB
sample03.txt WA 1 ms 256 KB