Submission #1727294
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount
#define INF INT_MAX/3
ll n,q;
ll crt[101010];
bool used[101010];
int main(){
cin>>n>>q;
rep(i,n)crt[i]=i;
used[0]=used[1]=true;
rep(i,q){
ll a,b;
cin>>a>>b;
a--; b--;
swap(crt[a],crt[b]);
if(crt[a]==0){
if(a>0)used[crt[a-1]]=true;
if(a<n-1)used[crt[a+1]]=true;
}
if(crt[b]==0){
if(b>0)used[crt[b-1]]=true;
if(b<n-1)used[crt[b+1]]=true;
}
}
ll res=0;
rep(i,n)if(used[i])res++;
cout<<res+1<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
G - Magician |
User |
yamad |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1148 Byte |
Status |
WA |
Exec Time |
57 ms |
Memory |
1024 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 100 |
Status |
|
|
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 |
WA |
57 ms |
1024 KB |
subtask1_02.txt |
AC |
57 ms |
1024 KB |
subtask1_03.txt |
WA |
56 ms |
1024 KB |
subtask1_04.txt |
AC |
56 ms |
1024 KB |
subtask1_05.txt |
AC |
57 ms |
1024 KB |
subtask1_06.txt |
AC |
56 ms |
1024 KB |
subtask1_07.txt |
WA |
56 ms |
1024 KB |
subtask1_08.txt |
WA |
56 ms |
1024 KB |
subtask1_09.txt |
WA |
56 ms |
1024 KB |
subtask1_10.txt |
WA |
56 ms |
1024 KB |
subtask1_11.txt |
WA |
56 ms |
1024 KB |
subtask1_12.txt |
WA |
56 ms |
1024 KB |
subtask1_13.txt |
WA |
56 ms |
1024 KB |
subtask1_14.txt |
WA |
56 ms |
1024 KB |
subtask1_15.txt |
WA |
56 ms |
1024 KB |
subtask1_16.txt |
WA |
56 ms |
1024 KB |
subtask1_17.txt |
WA |
56 ms |
1024 KB |
subtask1_18.txt |
WA |
56 ms |
1024 KB |
subtask1_19.txt |
AC |
56 ms |
1024 KB |