Submission #57863

#TimeUsernameProblemLanguageResultExecution timeMemory
57863okaybody10Teams (CEOI11_tea)C++98
0 / 100
2557 ms73480 KiB
#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 (stderr)

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;
                          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...