Submission #2143049


Source Code Expand

// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , Q , f[N];

int main(){
  scanf("%d%d",&n,&Q);
  int c = 1;
  f[2] = 1;
  rep(i,0,Q) {
    int a,b;
    scanf("%d%d",&a,&b);
    swap(f[a] , f[b]);
    if(c == a || c == b)
      c ^= a ^ b;
    if(c != 1) f[c - 1] = 1;
    if(c != n) f[c + 1] = 1;
  }
  f[c] = 1;
  int ans = 0;
  rep(i,1,n+1) ans += f[i];
  printf("%d\n",ans);
  return 0;
}

Submission Info

Submission Time
Task G - Magician
User Y_UME
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1175 Byte
Status AC
Exec Time 20 ms
Memory 640 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:41:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&n,&Q);
                      ^
./Main.cpp:46:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&a,&b);
                        ^

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 18 ms 640 KB
subtask1_02.txt AC 18 ms 640 KB
subtask1_03.txt AC 18 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 18 ms 640 KB
subtask1_08.txt AC 18 ms 640 KB
subtask1_09.txt AC 18 ms 640 KB
subtask1_10.txt AC 18 ms 640 KB
subtask1_11.txt AC 20 ms 640 KB
subtask1_12.txt AC 18 ms 640 KB
subtask1_13.txt AC 18 ms 640 KB
subtask1_14.txt AC 18 ms 640 KB
subtask1_15.txt AC 18 ms 640 KB
subtask1_16.txt AC 18 ms 640 KB
subtask1_17.txt AC 18 ms 640 KB
subtask1_18.txt AC 18 ms 640 KB
subtask1_19.txt AC 18 ms 640 KB