QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#319113 | #5033. Y 君的序列 | Harry27182 | Compile Error | / | / | C++14 | 2.1kb | 2024-02-01 21:45:23 | 2024-02-01 21:45:24 |
Judging History
answer
#include <bits/stdc++.h>
#include "seq.h"
using namespace std;
namespace A {
const int maxn=2e5;;
int n,M,b[maxn],a[maxn],tot,mk;
void WA1() {
puts("Invalid operation"); exit(0);
}
void WA2() {
puts("Wrong construction"); exit(0);
}
void WA3() {
puts("Too many operations"); exit(0);
}
int Get(int x) {
if (x<1||x>n) { puts("Invalid Get"); exit(0); }
return b[x];
}
void add(int x,int y) {
if (!mk) { puts("Wrong answer"); exit(0); }
if (x<1||x>n||y<1||y>n||x==y||a[x]%2!=0) WA1();
if (a[y]+a[x]/2>1e9) WA1();
a[y]+=a[x]/2,a[x]/=2;
tot++;
if (tot>M) WA3();
}
int F;
void answer(int flag) {
if (mk||flag!=F) { puts("Wrong answer"); exit(0); }
mk=1;
}
void main() {
scanf("%d %d %d",&n,&M,&F);
for (int i=1;i<=n;i++) scanf("%d",&b[i]),a[i]=i;
SEQ(n,M);
for (int i=1;i<=n;i++) if (a[i]!=b[i]) WA2();
puts("AC");
}
}
int Get(int x) {
return A::Get(x);
}
void add(int x,int y) {
printf("%d %d\n",x,y);
A::add(x,y);
}
void answer(int flag) {
A::answer(flag);
}
#include <bits/stdc++.h>
#include "seq.h"
using namespace std;
vector<int>v;vector<pair<int,int> >res;
int p[100005],b[100005],a[100005],pos[100005];
void solve(int x)
{
v.clear();v.emplace_back(x);
while(x>1)
{
int y=2;
while(y<x)y<<=1;
x=y+1-x;
v.emplace_back(x);
}
}
void work(int x,int y)
{
int nx=x,ny=y;
while(nx!=y)
{
if(nx%2==0)res.emplace_back(make_pair(p[x],p[y])),ny+=nx/2,nx-=nx/2;
else res.emplace_back(make_pair(p[y],p[x])),nx+=ny/2,ny-=ny/2;
}
swap(p[x],p[y]);
swap(a[p[x]],a[p[y]]);
}
void SEQ(int n,int M)
{
for(int i=1;i<=n;i++)b[i]=Get(i),a[i]=i,pos[b[i]]=i,p[i]=i;
for(int i=n;i>=1;i--)
{
if(a[pos[i]]==i)continue;
solve(a[pos[i]]);int now=0;
for(int j=0;j<v.size();j++)
{
if(now==0)now=v[j];
else work(now,v[j]),now=v[j];
}
solve(i);now=0;
for(int j=v.size()-1;j>=0;j--)
{
if(now==0)now=v[j];
else work(now,v[j]),now=v[j];
}
}
answer(1);
for(int i=0;i<res.size();i++)add(res[i].first,res[i].second);
}
int main() {
A::main();
return 0;
}
詳細信息
implementer.cpp: In function ‘void {anonymous}::StAr_WaRs::main()’: implementer.cpp:46:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 46 | scanf("%d %d",&n,&M); | ~~~~~^~~~~~~~~~~~~~~ implementer.cpp:47:45: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | for (int i=1;i<=n;i++) scanf("%d",&b[i]),a[i]=i; | ~~~~~^~~~~~~~~~~~ answer.code: In function ‘void A::main()’: answer.code:34:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d %d %d",&n,&M,&F); | ~~~~~^~~~~~~~~~~~~~~~~~~~~ answer.code:35:45: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | for (int i=1;i<=n;i++) scanf("%d",&b[i]),a[i]=i; | ~~~~~^~~~~~~~~~~~ /usr/bin/ld: /tmp/ccU368Ct.o: in function `Get(int)': answer.code:(.text+0x190): multiple definition of `Get(int)'; /tmp/cc9Ftbru.o:implementer.cpp:(.text+0x30): first defined here /usr/bin/ld: /tmp/ccU368Ct.o: in function `add(int, int)': answer.code:(.text+0x1d0): multiple definition of `add(int, int)'; /tmp/cc9Ftbru.o:implementer.cpp:(.text+0x80): first defined here /usr/bin/ld: /tmp/ccU368Ct.o: in function `answer(int)': answer.code:(.text+0x210): multiple definition of `answer(int)'; /tmp/cc9Ftbru.o:implementer.cpp:(.text+0x160): first defined here /usr/bin/ld: /tmp/ccU368Ct.o: in function `main': answer.code:(.text.startup+0xd0): multiple definition of `main'; /tmp/cc9Ftbru.o:implementer.cpp:(.text.startup+0x0): first defined here collect2: error: ld returned 1 exit status