답안 #288111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
288111 2020-09-01T08:49:20 Z 최은수(#5768) JOIRIS (JOI16_joiris) C++17
0 / 100
1 ms 396 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
vector<int>v;
vector<pi>qv;
int n,k;
inline void put(int t,int i)
{
    qv.eb(t,i);
    if(t==1)
        v[i]+=k;
    else
        for(int j=i;j<i+k;j++)
            v[j]++;
    return;
}
inline void cut()
{
    int mx=*max_element(1+all(v));
    for(int i=0;i++<n;)
        while(mx>=v[i]+k)
            put(1,i);
    int mn=*min_element(1+all(v));
    for(int i=0;i++<n;)
        v[i]-=mn;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>k;
    v.resize(n);
    for(int&t:v)
        cin>>t;
    v.insert(v.begin(),0);
    for(int i=2;i+k-1<=n;i++)
    {
        cut();
        if(v[i]!=v[i-1])
        {
            for(int j=0;j++<i;)
                if(j<i||j>=i+k)
                    put(1,j),put(1,j);
            while(v[i]%k!=v[i-1]%k)
                put(2,i);
        }
    }
    cut();
    for(int i=1;i<n;i++)
        if(v[i]!=v[i+1]&&i%k!=0)
            return cout<<-1<<endl,0;
    for(int i=1;i<n;i++)
        if(v[i]!=v[i+1])
            while(v[i]%k!=v[i+1]%k)
                for(int j=1;j<=i;j+=k)
                    put(2,j);
    cut();
    for(int i=0;i++<n;)
        if(v[i]!=0)
            return cout<<-1<<endl,0;
    cout<<qv.size()<<endl;
    for(pi&t:qv)
        cout<<t.fi<<' '<<t.se<<'\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Incorrect 1 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 396 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Incorrect 1 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Incorrect 1 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -