QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#97683 | #6319. Parallel Processing (Easy) | whatever# | WA | 3ms | 3780kb | C++14 | 2.7kb | 2023-04-17 22:04:01 | 2023-04-17 22:04:02 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define mod 998244353
using namespace std;
vector<vector<vector<int> > > ans;
void op(vector<vector<int> > v)
{
/* bitset<2005> A,B,C,D;
A=(s[v[0][1]]^s[v[0][2]]);
B=(s[v[1][1]]^s[v[1][2]]);
C=(s[v[2][1]]^s[v[2][2]]);
D=(s[v[3][1]]^s[v[3][2]]);
s[v[0][0]]=A;
s[v[1][0]]=B;
s[v[2][0]]=C;
s[v[3][0]]=D;*/
ans.push_back(v);
}
vector<vector<vector<int> > > solve(int n)
{
ans.clear();
// bitset<2005> s[2005];
int fa[2005]={},cnt[2005]={};
for(int i=1;i<=n;i++) fa[i]=i-1,cnt[i-1]=1;
for(int i=1;i<=n;i++)
{
vector<vector<int> > v;
bitset<2005> qwq;
qwq.reset();
int C=4;
for(int j=1;j<=n;j++)
{
if(fa[j]!=0&&cnt[j]&&!qwq[fa[j]])
{
v.push_back({j,fa[j],j});
--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
--C;
}
if(!C) break;
}
for(int j=1;j<=n;j++)
{
if(fa[j]!=0&&fa[fa[j]]==0&&!qwq[fa[j]])
{
v.push_back({j,fa[j],j});
--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]];
--C;
}
if(!C) break;
}
for(int j=1;j<=n;j++)
{
if(fa[j]!=0&&!qwq[fa[j]])
{
v.push_back({j,fa[j],j});
--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
--C;
}
if(!C) break;
}
if(v.size()==0) break;
while(v.size()<4) v.push_back({2,1,2});
op(v);
}
return ans;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
// for(int i=1;i<=n;i++) s[i][i]=1;
// for(int i=1;i<=n;i++) fa[i]=i-1,cnt[i-1]=1;
/* for(int i=1;i<=n;i++)
{
vector<vector<int> > v;
bitset<2005> qwq;
qwq.reset();
int C=4;
for(int j=1;j<=n;j++)
{
if(fa[j]!=0&&cnt[j]&&!qwq[fa[j]])
{
v.push_back({j,fa[j],j});
--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
--C;
}
if(!C) break;
}
for(int j=1;j<=n;j++)
{
if(fa[j]!=0&&fa[fa[j]]==0&&!qwq[fa[j]])
{
v.push_back({j,fa[j],j});
--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]];
--C;
}
if(!C) break;
}
for(int j=1;j<=n;j++)
{
if(fa[j]!=0&&!qwq[fa[j]])
{
v.push_back({j,fa[j],j});
--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
--C;
}
if(!C) break;
}
if(v.size()==0) break;
while(v.size()<4) v.push_back({2,1,2});
op(v);
}*/
vector<vector<vector<int> > > qwq;
for(int i=0;i<=10000;i++) qwq.push_back({{}});
for(int i=n;i<=n+4;i++)
{
vector<vector<vector<int> > > xx=solve(i);
if(xx.size()<qwq.size()) qwq=xx;
}
ans=qwq;
cout << ans.size() << "\n";
for(auto t:ans)
{
for(auto y:t)
{
for(auto x:y) cout << x << " ";
cout << "\n";
}
}
/* for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout << s[i][j];
}
cout << "\n";
}*/
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 3780kb
input:
2
output:
1 2 1 2 2 1 2 2 1 2 2 1 2
result:
ok AC
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3716kb
input:
4
output:
2 2 1 2 4 3 4 2 1 2 2 1 2 3 2 3 4 2 4 2 1 2 2 1 2
result:
wrong answer A[2] is not (1, …, 2)