QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#377533#7990. 广播Destiny#WA 8ms3972kbC++172.3kb2024-04-05 14:49:122024-04-05 14:49:12

Judging History

你现在查看的是最新测评结果

  • [2024-04-05 14:49:12]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3972kb
  • [2024-04-05 14:49:12]
  • 提交

answer

#include<bits/stdc++.h>
#ifndef xxx
#define dbg(...) ;
#endif
using namespace std;
template<class T> ostream &operator<<(ostream &o, const vector <T> &v) { bool f=false; for(T i:v) { f?o<<' ':o; o<<(i); f=true; } return o; }
template<class T> void sort(T &v) { std::sort(v.begin(), v.end()); }
template<class T, class C> void sort(T &v, C c) { std::sort(v.begin(), v.end(), c); }
template<class T> void reverse(T &v) { std::reverse(v.begin(), v.end()); }
template<class T> bool is_sorted(T &v) { return std::is_sorted(v.begin(), v.end()); }
template<class T> inline void _min(T &x, const T &y) { x>y?x=y:x; }
template<class T> inline void _max(T &x, const T &y) { x<y?x=y:x; }
istream &operator>>(istream &i, __int128_t &x) { x=0; short f=1; char c=0; while(!isdigit(c)) { if(c=='-')f=-1; c=i.get(); } while(isdigit(c))x=x*10+c-'0', c=i.get(); x*=f; return i; }
ostream &operator<<(ostream &o, __int128_t x) { if(x==0) { o<<0; return o; } bool f=false; string s; if(x<0)f=true, x=-x; while(x)s+=x%10+'0', x/=10; reverse(s); if(f)o<<'-'; o<<s; return o; }
mt19937 mt(time(0));
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
constexpr int maxn=2e5+5;
constexpr int mod=1e9+7;
constexpr int inf=0x3f3f3f3f;
constexpr ll INF=0x3f3f3f3f3f3f3f3fll;
constexpr double pi=acos(-1.0);
constexpr double eps=1e-9;

int main()//MARK: main
{
#ifndef xxx
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#endif
	cout<<fixed<<setprecision(10);
	int n, m;
	cin>>n>>m;
	vector<int>a(n), b(m);
	for(int &x:a)
		cin>>x;
	for(int &x:b)
		cin>>x;
	if(n>m)
	{
		swap(a, b);
		swap(n, m);
	}
	auto calc=[](vector<int> &a, vector<int> &b)->int
	{
		bool f=false;
		if(a.size()>b.size())
		{
			f=true;
			swap(a, b);
		}
		int ans=0;
		for(int i=a.size(); i>=1; i--)
		{
			int c=a.size()-i;
			int x=a[i-1];
			int y=b[b.size()-1-c];
			if(x==y||min(x, y)==1)
			{
				continue;
			}
			else
			{
				ans++;
			}
		}
		if(f)
		{
			swap(a, b);
		}
		return ans;
	};
	vector<int>na=a;
	vector<int>nb=b;
	int ans=inf;
	for(int i=m+1; i<=m+n; i++)
	{
		nb.push_back(1);
		_min(ans, calc(nb, a)+abs(m-i));
	}
	for(int i=m; i>=1; i--)
	{
		_min(ans, calc(na, b)+abs(m-i));
		na.push_back(1);
	}
	cout<<ans<<'\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3664kb

input:

4 2
2 1 3 2
4 2

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

1 1
2
3

output:

1

result:

ok single line: '1'

Test #3:

score: -100
Wrong Answer
time: 8ms
memory: 3972kb

input:

1997 1970
1235 1225 1169 368 1 1 1444 1 1189 775 788 114 1609 1169 821 1708 821 1370 1444 1356 775 1747 1661 775 1692 1960 788 1866 382 1444 1356 1868 309 788 1609 211 1160 1225 1370 1609 1692 1064 1356 788 1707 775 1707 1064 1356 1160 1692 368 129 1235 1868 1370 1160 775 368 129 1747 334 1503 1444 ...

output:

1839

result:

wrong answer 1st lines differ - expected: '1813', found: '1839'