QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#123136 | #5550. JOIRIS | lmeowdn | 0 | 1ms | 3692kb | C++14 | 2.1kb | 2023-07-11 19:38:56 | 2023-07-11 19:38:57 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
const int N=55;
int n,k,a[N],b[N],mx;
vp ans;
struct oper {
int op,x,t;
void print() {
rep(i,1,t) ans.eb(op,x);
}
};
vector<oper> tans;
bool work(int x) {
rep(i,1,n) b[i]=x;
tans.clear();
rep(i,1,n) {
if(b[i]<a[i]) return 0;
if(b[i]%k!=a[i]%k) {
if(i>n-k+1) return 0;
int tm=0;
while(b[i]%k!=a[i]%k) tm++, b[i]--;
tans.eb((oper){2,i,tm});
rep(j,i+1,i+k-1) b[j]-=tm;
}
if(b[i]!=a[i]) tans.eb((oper){1,i,(b[i]-a[i])/k});
}
reverse(tans.begin(),tans.end());
for(oper x:tans) x.print();
printf("%d\n",(int)ans.size());
for(auto [x,y]:ans) printf("%d %d\n",x,y);
return 1;
}
signed main() {
n=read(), k=read();
rep(i,1,n) a[i]=read(), chmax(mx,a[i]);
rep(x,mx,n*k+mx) if(work(x)) return 0;
puts("-1");
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 15
Accepted
time: 1ms
memory: 3448kb
input:
34 2 2 5 41 47 8 27 42 17 43 47 47 12 49 33 41 18 4 16 15 28 9 13 25 44 20 40 25 16 2 20 0 41 6 16
output:
-1
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3372kb
input:
26 2 32 42 0 0 20 22 4 19 13 37 22 30 50 17 23 1 11 7 22 3 26 25 45 32 38 38
output:
-1
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3448kb
input:
32 2 3 42 8 32 34 44 2 4 19 40 49 47 25 6 46 7 40 22 38 6 32 45 4 35 16 29 47 6 1 22 0 14
output:
-1
result:
ok
Test #4:
score: -15
Wrong Answer
time: 1ms
memory: 3692kb
input:
28 2 9 21 26 30 0 46 33 7 36 29 28 0 33 21 29 37 15 44 33 14 14 34 32 4 49 23 48 19
output:
343 1 28 1 28 1 28 1 28 1 28 1 28 1 28 1 28 1 28 1 28 1 28 1 28 1 28 1 28 1 28 2 27 1 26 1 26 1 26 1 26 1 26 1 26 1 26 1 26 1 26 1 26 1 26 1 26 1 26 2 26 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 1 24 2 24 1 23 1 23 1 23 1 23 1 23 1 23 1...
result:
wrong answer
Subtask #2:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 0ms
memory: 3680kb
input:
3 2 38 27 0
output:
26 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 2 1 2 1 2 1 2 2 2 2 1
result:
wrong answer
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%