답안 #1111372

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111372 2024-11-12T07:49:57 Z khoaha123 Teams (CEOI11_tea) C++17
0 / 100
211 ms 24828 KB
#include <bits/stdc++.h>
#define endl '\n'
#define ii pair<int,int>
#define task ""
#define all(x) x.begin(),x.end()
using namespace std;
const int N = 1e6 + 5;
const int mod =  1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;
const int dx[2] = {1,0};
const int dy[2] = {0,1};

int n,a[N];
ii b[N];
vector<vector<int>> ans;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    if (fopen(task".INP","r")){
        freopen(task".INP","r",stdin);
        freopen(task".OUT","w",stdout);
    }
    cin >> n;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        b[i] = ii(a[i],i);
    }
    sort(b+1,b+1+n,greater<ii>());

    int i = 1;
    int res = 1;
    int cnt = 1;
    //3 2 2 2 1
    while (i <= n){
        i++;
        if (cnt >= b[i-cnt].first){
            vector<int> x;
            for (int j = i - cnt; j < i; ++j) x.push_back(b[j].second);
            ans.push_back(x);
            cnt = 1;
        }
        else {
            cnt++;
        }
    }
    cout << ans.size() << endl;
    for (auto f : ans){
        cout << f.size() << ' ';
        for (auto g : f) cout << g << ' ';
        cout << endl;
    }
    return 0;
}

Compilation message

tea.cpp: In function 'int main()':
tea.cpp:33:9: warning: unused variable 'res' [-Wunused-variable]
   33 |     int res = 1;
      |         ^~~
tea.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
tea.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(task".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Incorrect 1 ms 2384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 5372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 5456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 145 ms 19272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 197 ms 23212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 211 ms 24828 KB Output isn't correct
2 Halted 0 ms 0 KB -