QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#116629 | #6320. Parallel Processing (Hard) | c20231020 | AC ✓ | 1ms | 3640kb | C++14 | 9.4kb | 2023-06-29 17:08:35 | 2023-06-29 17:08:38 |
Judging History
answer
/*
膜拜传奇特级宗师 Afterglow 大神儿
今天在 florr 首页称您为大夏尊贵的大名儿
一股敬佩之情油生然而
您在 florr 为国争光,扬我大夏威名
向您献上最真挚的膜拜!!!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
*/
/*
_____ _____ _____ _____
/\ \ /\ \ /\ \ /\ \
/ \ \ / \ \ / \____\ / \ \
\ \ \ / \ \ / / / \ \ \
\ \ \ / \ \ / / / \ \ \
\ \ \ / /\ \ \ / /____/ \ \ \
\ \ \ / / \ \ \ / | | \ \ \
\ \ \ / / \ \ \ / | | \ \ \
\ \ \ / / / \ \ \ / | | \ \ \
\ \ \ / / / \ \ \ / |____|__ _____ \ \ \
_______________\ \____\/ /____/ \ \ \ / /| \ \ _______________\ \____\
\ / /\ \ \ \ \ \\ / | _________\____\\ / /
\ ____________/____/ \ \ \ \ \____\\/__| | | \ ____________/____/
\ \ \ \ \ \ | | | | | | \ \ \
\ \ \ \ \ \ | | | | | | \ \ \
\ \ \ \ \ \ | |____| | | | \ \ \
\ \ \ \ \ \ / / / \ | | \ \ \
\ \ \ \ \ \/ / / \ | | \ \ \
\ \____\ \ \___/ / / \ | | \ \____\
\ / / \ / / \| | \ / /
\/____/ \_______/____/ \____| \/____/
*/
#define poj
#define zcz
#ifdef poj
//C++
#include<iomanip>
#include<iostream>
//C
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
//STL
#include<algorithm>
#include<bitset>
#include<functional>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
//C++11
#if __cplusplus>=201103L
#include<chrono>
#include<random>
#include<unordered_set>
#include<unordered_map>
#endif
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#ifdef zcz
class fastin{
private:
#ifdef poj
static const int MAXBF=1<<20;
#else
const int MAXBF=1<<27;
#endif
FILE *inf;
char *inbuf,*inst,*ined;
inline char _getchar(){
if(inst==ined)inst=inbuf,ined=inbuf+fread(inbuf,1,MAXBF,inf);
return inst==ined?EOF:*inst++;
}
public:
fastin(FILE*_inf=stdin){
inbuf=new char[MAXBF],inf=_inf,inst=inbuf,ined=inbuf;
}
~fastin(){delete inbuf;}
template<typename Int> fastin&operator>>(Int &n){
static char c;
Int t=1;
while((c=_getchar())<'0'||c>'9')if(c=='-')t=-1;
n=(c^48);
while((c=_getchar())>='0'&&c<='9')n=n*10+(c^48);
n*=t;
return *this;
}
fastin&operator>>(char&c){
while((c=_getchar())<'!'||c>'~');
return *this;
}
fastin&operator>>(char*s){
int t=0;
static char c;
while((c=_getchar())==' '||c=='\n');
s[t++]=c;
while((c=_getchar())>='!'&&c<='~')s[t++]=c;
s[t]='\0';
return *this;
}
}fi;
class fastout{
private:
#ifdef poj
static const int MAXBF=1<<20;
#else
const int MAXBF=1<<27;
#endif
FILE *ouf;
char *oubuf,*oust,*oued;
inline void _flush(){fwrite(oubuf,1,oued-oust,ouf);oued=oust;}
inline void _putchar(char c){
if(oued==oust+MAXBF)_flush(),oued=oubuf;
*oued++=c;
#ifdef local
_flush();
#endif
}
public:
fastout(FILE*_ouf=stdout){
oubuf=new char[MAXBF],ouf=_ouf,oust=oubuf,oued=oubuf;
}
~fastout(){_flush();delete oubuf;}
template<typename Int> fastout&operator<<(Int n){
if(n<0)_putchar('-'),n=-n;
static char S[20];
int t=0;
do{S[t++]='0'+n%10,n/=10;}while(n);
for(int i=0;i<t;++i)_putchar(S[t-i-1]);
return *this;
}
fastout&operator<<(char c){_putchar(c);return *this;}
fastout&operator<<(char*s){
for(int i=0;s[i];++i)_putchar(s[i]);
return *this;
}
fastout&operator<<(const char*s){
for(int i=0;s[i];++i)_putchar(s[i]);
return *this;
}
}fo;
#define cin fi
#define cout fo
#else
#define czc ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#endif
#define mod7 1000000007
#define mod9 998244353
#define ll long long
#define isinf 0x3f3f3f3f
#define ilinf 0x7fffffff
#define lsinf 0x3f3f3f3f3f3f3f3f
#define llinf 0x7fffffffffffffff
#define pii pair<int,int>
#define fr first
#define sc second
#define next ___
#define pb push_back
#define N 500010
#define M 5000010
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b,c) for(int i=(a);i<=(b);i+=c)
#define Per(i,a,b,c) for(int i=(a);i>=(b);i-=c)
#define Gra(i) for(int i=h[x];i;i=next[i])
typedef int arr[N];
typedef int arm[M];
typedef ll arl[N];
typedef ll alm[M];
typedef double ard[N];
typedef double adm[M];
namespace modint{
template<typename Int,Int mod,Int m1>
struct modint{
Int v;
modint(){v=0;}
modint(Int a){v=a;}
bool operator==(modint a){return v==a.v;}
bool operator!=(modint a){return v!=a.v;}
bool operator<(modint a){return v<a.v;}
bool operator>(modint a){return v>a.v;}
bool operator<=(modint a){return v<=a.v;}
bool operator>=(modint a){return v>=a.v;}
bool operator==(Int a){return v==a;}
bool operator!=(Int a){return v!=a;}
bool operator<(Int a){return v<a;}
bool operator>(Int a){return v>a;}
bool operator<=(Int a){return v<=a;}
bool operator>=(Int a){return v>=a;}
modint operator+(modint a){return v>=mod-a.v?v-mod+a.v:v+a.v;}
modint operator-(modint a){return v>=a.v?v-a.v:v+mod-a.v;}
modint modnum(modint a){
return a-((__int128(a.v)*m1)>>80)*mod;
}
modint operator*(modint a){return modnum(v*a.v);}
modint operator+=(modint a){*this=*this+a;return *this;}
modint operator-=(modint a){*this=*this-a;return *this;}
modint operator*=(modint a){*this=*this*a;return *this;}
modint qpow(modint a,Int b){
modint r(1);
for(;b;b>>=1,a*=a)if(b&1)r*=a;
return r;
}
modint operator/(modint a){return qpow(a,mod-2)*v;}
modint operator/=(modint a){*this=*this/a;return *this;}
modint&operator++(){*this=*this+1;return *this;}
modint&operator--(){*this=*this-1;return *this;}
const modint operator++(int){modint r=*this;++*this;return r;}
const modint operator--(int){modint r=*this;--*this;return r;}
#ifdef cout
friend fastin&operator>>(fastin&in,modint&n){in>>n.v;return in;}
friend fastout&operator<<(fastout&out,modint n){out<<n.v;return out;}
#else
friend istream&operator>>(istream&in,modint&n){in>>n.v;return in;}
friend ostream&operator<<(ostream&out,modint n){out<<n.v;return out;}
#endif
};
typedef modint<long long,1000000007,1208925811152148> int7;
typedef modint<long long,998244353,1211051999424262> int9;
}
using namespace modint;
vector<tuple<int,int,int>>ans;
void f(int a,int b,int c){ans.pb({a,b,c});}
void g(){ans.pb({2000,2000,2000});}
void solve(int n){
if(n==2){
f(2,1,2);g();g();g();
}else if(n==3){
f(2,1,2);g();g();g();
f(3,2,3);g();g();g();
}else if(n==4){
f(2,1,2);f(4,3,4);g();g();
f(3,2,3);f(4,2,4);g();g();
}else if(n==5){
f(2,1,2);f(4,3,4);g();g();
f(3,2,3);f(4,2,4);g();g();
f(5,4,5);g();g();g();
}else if(n==6){
f(2,1,2);f(4,3,4);f(6,5,6);g();
f(3,2,3);f(4,2,4);g();g();
f(5,4,5);f(6,4,6);g();g();
}else if(n==7){
f(2,1,2);f(4,3,4);f(6,5,6);g();
f(3,2,3);f(4,2,4);f(7,6,7);g();
f(5,4,5);f(6,4,6);f(7,4,7);g();
}else if(n==8){
f(2,1,2);f(4,3,4);f(6,5,6);f(8,7,8);
f(3,2,3);f(4,2,4);f(7,6,7);f(8,6,8);
f(5,4,5);f(6,4,6);f(7,4,7);f(8,4,8);
}else if(n==9){
f(2,1,2);f(4,3,4);f(6,5,6);f(8,7,8);
f(3,2,3);f(4,2,4);f(8,6,8);g();
f(5,4,5);f(6,4,6);f(8,4,8);g();
f(7,6,7);f(9,8,9);g();g();
}else if(n==10){
f(2,1,2);f(4,3,4);f(6,5,6);f(8,7,8);
f(3,2,3);f(4,2,4);f(10,9,10);f(8,6,8);
f(5,4,5);f(6,4,6);f(8,4,8);g();
f(7,6,7);f(9,8,9);f(10,8,10);g();
}else if(n==11){
f(2,1,2);f(4,3,4);f(6,5,6);f(8,7,8);
f(3,2,3);f(4,2,4);f(10,9,10);f(8,6,8);
f(5,4,5);f(6,4,6);f(11,10,11);f(8,4,8);
f(7,6,7);f(9,8,9);f(10,8,10);f(11,8,11);
}else{
solve(n-5);
tuple<int,int,int> a[4]={ans.back()};
ans.pop_back();
For(i,1,3){
a[i]=ans.back();
ans.pop_back();
if(get<0>(a[i])==n-5)swap(a[0],a[i]);
}
f(n-3,n-4,n-3);f(n-1,n-2,n-1);ans.pb(a[0]);ans.pb(a[1]);
f(n-3,n-5,n-3);f(n,n-1,n);ans.pb(a[2]);ans.pb(a[3]);
f(n-4,n-5,n-4);f(n-2,n-3,n-2);f(n-1,n-3,n-1);f(n,n-3,n);
}
}
void solve(){
int n;
cin>>n;
solve(n);
cout<<ans.size()/4<<'\n';
for(auto [x,y,z]:ans)cout<<x<<' '<<y<<' '<<z<<'\n';
return;
}
int main(){
#ifndef zcz
czc;
#endif
int t=1;
while(t--)solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3528kb
input:
17
output:
7 2 1 2 4 3 4 6 5 6 2000 2000 2000 3 2 3 4 2 4 7 6 7 2000 2000 2000 9 8 9 11 10 11 7 4 7 2000 2000 2000 9 7 9 12 11 12 6 4 6 5 4 5 14 13 14 16 15 16 12 9 12 11 9 11 14 12 14 17 16 17 10 9 10 8 7 8 13 12 13 15 14 15 16 14 16 17 14 17
result:
ok AC
Test #2:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
18
output:
7 2 1 2 4 3 4 6 5 6 8 7 8 3 2 3 4 2 4 7 6 7 8 6 8 10 9 10 12 11 12 8 4 8 7 4 7 10 8 10 13 12 13 6 4 6 5 4 5 15 14 15 17 16 17 13 10 13 12 10 12 15 13 15 18 17 18 11 10 11 9 8 9 14 13 14 16 15 16 17 15 17 18 15 18
result:
ok AC
Test #3:
score: 0
Accepted
time: 1ms
memory: 3488kb
input:
19
output:
8 2 1 2 4 3 4 6 5 6 8 7 8 3 2 3 4 2 4 8 6 8 2000 2000 2000 5 4 5 6 4 6 8 4 8 2000 2000 2000 11 10 11 13 12 13 9 8 9 2000 2000 2000 11 9 11 14 13 14 2000 2000 2000 7 6 7 16 15 16 18 17 18 14 11 14 13 11 13 16 14 16 19 18 19 12 11 12 10 9 10 15 14 15 17 16 17 18 16 18 19 16 19
result:
ok AC
Test #4:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
20
output:
8 2 1 2 4 3 4 6 5 6 8 7 8 3 2 3 4 2 4 10 9 10 8 6 8 5 4 5 6 4 6 8 4 8 2000 2000 2000 12 11 12 14 13 14 10 8 10 2000 2000 2000 12 10 12 15 14 15 9 8 9 7 6 7 17 16 17 19 18 19 15 12 15 14 12 14 17 15 17 20 19 20 13 12 13 11 10 11 16 15 16 18 17 18 19 17 19 20 17 20
result:
ok AC
Test #5:
score: 0
Accepted
time: 1ms
memory: 3568kb
input:
21
output:
8 2 1 2 4 3 4 6 5 6 8 7 8 3 2 3 4 2 4 10 9 10 8 6 8 5 4 5 6 4 6 11 10 11 8 4 8 13 12 13 15 14 15 11 8 11 10 8 10 13 11 13 16 15 16 9 8 9 7 6 7 18 17 18 20 19 20 16 13 16 15 13 15 18 16 18 21 20 21 14 13 14 12 11 12 17 16 17 19 18 19 20 18 20 21 18 21
result:
ok AC
Test #6:
score: 0
Accepted
time: 1ms
memory: 3400kb
input:
120
output:
48 2 1 2 4 3 4 6 5 6 8 7 8 3 2 3 4 2 4 10 9 10 8 6 8 5 4 5 6 4 6 8 4 8 2000 2000 2000 12 11 12 14 13 14 10 8 10 2000 2000 2000 12 10 12 15 14 15 9 8 9 7 6 7 17 16 17 19 18 19 15 12 15 14 12 14 17 15 17 20 19 20 13 12 13 11 10 11 22 21 22 24 23 24 20 17 20 19 17 19 22 20 22 25 24 25 18 17 18 16 15 16...
result:
ok AC
Test #7:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
421
output:
168 2 1 2 4 3 4 6 5 6 8 7 8 3 2 3 4 2 4 10 9 10 8 6 8 5 4 5 6 4 6 11 10 11 8 4 8 13 12 13 15 14 15 11 8 11 10 8 10 13 11 13 16 15 16 9 8 9 7 6 7 18 17 18 20 19 20 16 13 16 15 13 15 18 16 18 21 20 21 14 13 14 12 11 12 23 22 23 25 24 25 21 18 21 20 18 20 23 21 23 26 25 26 19 18 19 17 16 17 28 27 28 30...
result:
ok AC
Test #8:
score: 0
Accepted
time: 1ms
memory: 3424kb
input:
464
output:
186 2 1 2 4 3 4 6 5 6 8 7 8 3 2 3 4 2 4 8 6 8 2000 2000 2000 5 4 5 6 4 6 8 4 8 2000 2000 2000 11 10 11 13 12 13 9 8 9 2000 2000 2000 11 9 11 14 13 14 2000 2000 2000 7 6 7 16 15 16 18 17 18 14 11 14 13 11 13 16 14 16 19 18 19 12 11 12 10 9 10 21 20 21 23 22 23 19 16 19 18 16 18 21 19 21 24 23 24 17 1...
result:
ok AC
Test #9:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
812
output:
325 2 1 2 4 3 4 6 5 6 2000 2000 2000 3 2 3 4 2 4 7 6 7 2000 2000 2000 9 8 9 11 10 11 7 4 7 2000 2000 2000 9 7 9 12 11 12 6 4 6 5 4 5 14 13 14 16 15 16 12 9 12 11 9 11 14 12 14 17 16 17 10 9 10 8 7 8 19 18 19 21 20 21 17 14 17 16 14 16 19 17 19 22 21 22 15 14 15 13 12 13 24 23 24 26 25 26 22 19 22 21...
result:
ok AC
Test #10:
score: 0
Accepted
time: 1ms
memory: 3476kb
input:
862
output:
345 2 1 2 4 3 4 6 5 6 2000 2000 2000 3 2 3 4 2 4 7 6 7 2000 2000 2000 9 8 9 11 10 11 7 4 7 2000 2000 2000 9 7 9 12 11 12 6 4 6 5 4 5 14 13 14 16 15 16 12 9 12 11 9 11 14 12 14 17 16 17 10 9 10 8 7 8 19 18 19 21 20 21 17 14 17 16 14 16 19 17 19 22 21 22 15 14 15 13 12 13 24 23 24 26 25 26 22 19 22 21...
result:
ok AC
Test #11:
score: 0
Accepted
time: 1ms
memory: 3476kb
input:
996
output:
398 2 1 2 4 3 4 6 5 6 8 7 8 3 2 3 4 2 4 10 9 10 8 6 8 5 4 5 6 4 6 11 10 11 8 4 8 13 12 13 15 14 15 11 8 11 10 8 10 13 11 13 16 15 16 9 8 9 7 6 7 18 17 18 20 19 20 16 13 16 15 13 15 18 16 18 21 20 21 14 13 14 12 11 12 23 22 23 25 24 25 21 18 21 20 18 20 23 21 23 26 25 26 19 18 19 17 16 17 28 27 28 30...
result:
ok AC
Test #12:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
997
output:
399 2 1 2 4 3 4 6 5 6 2000 2000 2000 3 2 3 4 2 4 7 6 7 2000 2000 2000 9 8 9 11 10 11 7 4 7 2000 2000 2000 9 7 9 12 11 12 6 4 6 5 4 5 14 13 14 16 15 16 12 9 12 11 9 11 14 12 14 17 16 17 10 9 10 8 7 8 19 18 19 21 20 21 17 14 17 16 14 16 19 17 19 22 21 22 15 14 15 13 12 13 24 23 24 26 25 26 22 19 22 21...
result:
ok AC
Test #13:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
998
output:
399 2 1 2 4 3 4 6 5 6 8 7 8 3 2 3 4 2 4 7 6 7 8 6 8 10 9 10 12 11 12 8 4 8 7 4 7 10 8 10 13 12 13 6 4 6 5 4 5 15 14 15 17 16 17 13 10 13 12 10 12 15 13 15 18 17 18 11 10 11 9 8 9 20 19 20 22 21 22 18 15 18 17 15 17 20 18 20 23 22 23 16 15 16 14 13 14 25 24 25 27 26 27 23 20 23 22 20 22 25 23 25 28 2...
result:
ok AC
Test #14:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
999
output:
400 2 1 2 4 3 4 6 5 6 8 7 8 3 2 3 4 2 4 8 6 8 2000 2000 2000 5 4 5 6 4 6 8 4 8 2000 2000 2000 11 10 11 13 12 13 9 8 9 2000 2000 2000 11 9 11 14 13 14 2000 2000 2000 7 6 7 16 15 16 18 17 18 14 11 14 13 11 13 16 14 16 19 18 19 12 11 12 10 9 10 21 20 21 23 22 23 19 16 19 18 16 18 21 19 21 24 23 24 17 1...
result:
ok AC
Test #15:
score: 0
Accepted
time: 1ms
memory: 3464kb
input:
1000
output:
400 2 1 2 4 3 4 6 5 6 8 7 8 3 2 3 4 2 4 10 9 10 8 6 8 5 4 5 6 4 6 8 4 8 2000 2000 2000 12 11 12 14 13 14 10 8 10 2000 2000 2000 12 10 12 15 14 15 9 8 9 7 6 7 17 16 17 19 18 19 15 12 15 14 12 14 17 15 17 20 19 20 13 12 13 11 10 11 22 21 22 24 23 24 20 17 20 19 17 19 22 20 22 25 24 25 18 17 18 16 15 1...
result:
ok AC