답안 #57863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57863 2018-07-16T12:35:27 Z okaybody10 Teams (CEOI11_tea) C++
0 / 100
2500 ms 73480 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
vector<int> ans[1000006];
pii v[1000006];
int idx=0,pos,copyidx;
void q2()
{
    copyidx=idx;
    while(v[pos].first>pos+1 && pos>0) { ans[copyidx][0]++,ans[copyidx].push_back(v[pos--].second); if(--copyidx<0) copyidx=idx; }
}
void q1()
{
    ans[idx].push_back(v[pos].first);
    for(int i=0;i<ans[idx][0];i++) ans[idx].push_back(v[pos--].second);
    idx++;
}
int main()
{
    int n; scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&v[i].first),v[i].second=i+1;
    sort(v,v+n);
    pos=n-1;
    while(pos>=0)
    {
        if(v[pos].first>pos+1) q2();
        else q1();
    }
    printf("%d\n",idx);
    for(int i=0;i<idx;i++)
    {
        printf("%d ",ans[i][0]);
        for(int j=0;j<ans[i][0];j++) printf("%d ",ans[i][j+1]);
        printf("\n");
    }
}

Compilation message

tea.cpp: In function 'int main()':
tea.cpp:20:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n; scanf("%d",&n);
            ~~~~~^~~~~~~~~
tea.cpp:21:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++) scanf("%d",&v[i].first),v[i].second=i+1;
                          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 23804 KB Output is correct
2 Execution timed out 2557 ms 23968 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 59 ms 47640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 49 ms 47740 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 55 ms 47936 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 64 ms 48032 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 72 ms 50428 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 94 ms 50972 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 246 ms 67516 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 318 ms 72496 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 497 ms 73480 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -