QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#391677 | #3791. Interesting Calculator | ucup-team1251 | 0 | 0ms | 6696kb | C++17 | 2.2kb | 2024-04-16 18:00:10 | 2024-04-16 18:00:10 |
answer
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<math.h>
#include<set>
#include<bitset>
#include<deque>
#include<unordered_map>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int>PII;
const int N=2e5+10,M=5e2+10;
int n,m;
int l[N],r[N],idx,a[N];
void df()
{
int oo=0;
while(cin>>n>>m)
{
memset(l,0,sizeof(l));
memset(r,0,sizeof(r));
// int he=0,en=n+1;
for(int i=0;i<=n+1;i++)
{
l[i]=i-1;
r[i]=i+1;
}
// for(int i=1;i<=n;i++)cout<<l[i]<<" ";cout<<endl;
int num=0;
while(m--)
{
int t,x,y;
cin>>t;
if(t==4)
{
num++;
int t1=r[0],t2=l[n+1];
r[0]=t2;
l[0]=t2;
l[n+1]=t1;
r[n+1]=t1;
}
else if(t==1)
{
cin>>x>>y;
if(num%2==0)
{
if(l[y]==x)continue;
else
{
//现将x删除,再添加;
r[l[x]]=r[x];
l[r[x]]=l[x];
r[l[y]]=x;
l[x]=l[y];
r[x]=y;
l[y]=x;
}
}
else
{
if(r[y]==x)continue;
else
{
r[l[x]]=r[x];
l[r[x]]=l[x];
l[r[y]]=x;
r[x]=r[y];
r[y]=x;
l[x]=y;
}
}
}
else if(t==2)
{
cin>>x>>y;
if(num%2==0)
{
if(r[y]==x)continue;
else
{
r[l[x]]=r[x];
l[r[x]]=l[x];
r[x]=r[y];
l[r[y]]=x;
r[y]=x;
l[x]=y;
}
}
else
{
if(l[y]==x)continue;
else
{
r[l[x]]=r[x];
l[r[x]]=l[x];
l[x]=l[y];
r[l[y]]=x;
l[y]=x;
r[x]=y;
}
}
}
else
{
cin>>x>>y;
int ii=r[x],jj=l[y];
int p1=l[x],p2=r[y];
l[ii]=y;
r[y]=ii;
l[y]=p1;
r[p1]=y;
l[p2]=x;
r[x]=p2;
l[x]=jj;
r[jj]=x;
}
}
int ans=0;
int tt=r[0];
// cout<<tt<<endl;
if(num%2==0)
{
for(int i=1;i<=n;i++)
{
if(i%2)
ans+=tt;
tt=r[tt];
}
}
else
{
// cout<<l[100000]<<"[[["<<endl;
for(int i=1;i<=n;i++)
{
if(i%2)ans+=tt;
tt=l[tt];
// cout<<tt<<" ";
}
}
cout<<"Case "<<++oo<<": "<<ans<<endl;
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie();
cout.tie();
int t=1;
// cin>>t;
while(t--)
{
df();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 6696kb
input:
12 256 100 100 100 1 100 100 100 100 100 100 6 5 4 3 2 1 2 3 4 5 100 100 10 100 100 100 100 100 100 100 12 256 100 100 100 1 100 100 100 100 100 100 100 100 100 100 100 1 100 100 100 100 100 100 10 100 100 100 100 100 100 100 1 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 10...
output:
Case 1: 59004 Case 2: 49348110
result:
wrong answer 1st lines differ - expected: 'Case 1: 9 4', found: 'Case 1: 59004'