新型WA的一个未知错误?
  • 板块学术版
  • 楼主紊莫turtle
  • 当前回复7
  • 已保存回复7
  • 发布时间2023/1/14 20:40
  • 上次更新2023/10/24 04:13:47
查看原帖
新型WA的一个未知错误?
443675
紊莫turtle楼主2023/1/14 20:40

WA的一个未知错误:wrong output format Expected EOLN
在做
https://www.luogu.com.cn/problem/P2578 时WA60pts,这个报错提示学了两年半OI都没见过。。
代码大概是对的?

//Author: Velvet on Luogu(uid=443675)
#include <bits/stdc++.h>
#define int long long
#define mkpr make_pair
#define fi first
#define se second
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define dF(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
using namespace __gnu_cxx;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
inline void write(int x){if (x < 0) x = ~x + 1, putchar('-');if (x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(int x){write(x);putchar('\n');}
inline void writesp(int x){write(x);putchar(' ');}
inline int lowbit(int x) {return x&(-x);}
typedef pair<int,int> Pair;
const int N=15;
int a[N][N],b[N][N];
unordered_map<int,int> M,pre;
void work(int n){
	dF(i,3,1)dF(j,3,1){
		b[i][j]=n%10;n/=10;
	}
}
int c1(){
	int sum=0,t=b[1][1];
	b[1][1]=b[2][1],b[2][1]=b[3][1],b[3][1]=b[3][2];b[3][2]=b[3][3],b[3][3]=b[2][3],b[2][3]=b[1][3],b[1][3]=b[1][2],b[1][2]=t;
	F(i,1,3)F(j,1,3){
		sum=sum*10+b[i][j];
	}return sum;
}
int c2(){
	int sum=0,t=b[2][1];
	b[2][1]=b[2][3];b[2][3]=b[2][2];b[2][2]=t;
	F(i,1,3)F(j,1,3){
		sum=sum*10+b[i][j];
	}return sum;
}
int check(){
	F(i,1,3)F(j,1,3){
		if(b[i][j]!=3*(i-1)+j-1) return 0;
	}return 1;
}
void print(int now){
	if(pre[now]) print(pre[now]);
	work(now);
	F(i,1,3){
		F(j,1,3){
			cout<<b[i][j]<<' ';
		}cout<<endl;
	}cout<<endl;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int sum=0;
    F(i,1,3)F(j,1,3){
		cin>>a[i][j];
		sum=sum*10+a[i][j];
	}
	queue<Pair> Q;
	Q.push({sum,0});
	while(Q.size()){
		int now=Q.front().fi,s=Q.front().se;
		Q.pop(); M[now]=1;
		work(now);
		if(check()){
			cout<<s<<endl;
			print(now);return 0;
		}
		int l=c1();
		work(now);
		int r=c2();
		if(!M[l]){
			pre[l]=now;
			Q.push({l,s+1});
		}if(!M[r]){
			pre[r]=now;
			Q.push({r,s+1});
		}
	}cout<<"UNSOLVABLE";
    return 0;
}
2023/1/14 20:40
加载中...