Submission #1986313


Source Code Expand

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int main() {
    int n, q;
    cin >> n >> q;
    int x = 0;
    VI a(n);
    a[0] = a[1] = 1;
    while (q--){
        int s, t;
        scanf("%d %d", &s, &t);
        s--;
        t--;
        swap(a[s], a[t]);
        if (x == s) x = t;
        else if (x == t) x = s;

        if (x > 0) a[x-1] = 1;
        if (x < n-1) a[x+1] = 1;
    }

    int ans = 0;
    REP(i,n) ans += a[i];
    cout << ans << endl;

    return 0;
}

Submission Info

Submission Time
Task G - Magician
User TangentDay
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1114 Byte
Status AC
Exec Time 19 ms
Memory 768 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:39:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &s, &t);
                               ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 23
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
subtask1_01.txt AC 19 ms 640 KB
subtask1_02.txt AC 19 ms 640 KB
subtask1_03.txt AC 19 ms 640 KB
subtask1_04.txt AC 18 ms 640 KB
subtask1_05.txt AC 18 ms 640 KB
subtask1_06.txt AC 18 ms 640 KB
subtask1_07.txt AC 19 ms 640 KB
subtask1_08.txt AC 18 ms 640 KB
subtask1_09.txt AC 19 ms 768 KB
subtask1_10.txt AC 19 ms 640 KB
subtask1_11.txt AC 19 ms 640 KB
subtask1_12.txt AC 19 ms 640 KB
subtask1_13.txt AC 19 ms 640 KB
subtask1_14.txt AC 19 ms 640 KB
subtask1_15.txt AC 19 ms 640 KB
subtask1_16.txt AC 19 ms 640 KB
subtask1_17.txt AC 19 ms 640 KB
subtask1_18.txt AC 18 ms 640 KB
subtask1_19.txt AC 18 ms 640 KB