답안 #731674

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
731674 2023-04-27T18:29:29 Z thegamercoder19 Baloni (COCI15_baloni) C++14
0 / 100
981 ms 129012 KB
/*
Coded by thegamercoder19
GL
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846
#define FILER 0
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = pow(10, 9) + 7;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const ull INFUL = 0x3f3f3f3f3f3f3f3f;
const ll INFT = 0x3f3f3f3f;
const ll MAX = 2e5 + 1;
const ll MODD = 998244353;
const double EPS = 1e-10;
#define V vector
#define pll pair<ll, ll>
#define pull2 pair<ull,ull>
#define MS multiset
#define M map
#define Q queue
#define PQ priority_queue
#define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c)
#define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c)
#define FORA(a,i) for(auto &i : a)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define sorta(a) sort(all(a))
#define sortd(a) sort(all(a), greater<ll>())
#define setp(x) setprecision(x)<<fixed
#define RET return
#define log(a,b) log(b)/log(a)
#define WH(s) while(s)
#define WHI(t) WH(t--)
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define YESNO(s) cout << (s ? "YES" : "NO") << endl;
#define YesNo(s) cout<<(s?"Yes":"No")<<endl;
#define TYP 0
using namespace std;
ll n, res, x;
map<ll, set<ll>> m;
V<set<ll>> g;
V<bool> used;

void dfs(ll u)
{
    used[u] = 1;
    FORA(g[u], v)if (!used[v])dfs(v);
}
void solve()
{
    cin >> n;
    used.resize(n + 1);
    g.resize(n + 1);
    FOR(ll, i, 1, n + 1, 1)cin >> x, m[x].insert(i);
    FORA(m, mi)
        FORA(mi.second, i)
    {
        auto j = m[mi.first - 1].upper_bound(i);
        if (j != m[mi.first - 1].end()) g[i].insert(*j);
    }

FOR(ll,i,1,n+1,1)
if (!used[i])
{
    dfs(i);
    res++;
}
cout << res << endl;
     
}
void init()
{
  
    if (FILER)
    {
        freopen("mootube.in", "r", stdin);
        freopen("mootube.out", "w", stdout);
    }
    // freopen("out","w",stdout);

}
void handle()
{
    init();
    ll t = 1;
    if (TYP)cin >> t;
    //getline(cin, s);
    WHI(t)solve();
}

int main()
{
    IOF
        handle();
    RET 0;
}

Compilation message

baloni.cpp: In function 'void init()':
baloni.cpp:85:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |         freopen("mootube.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
baloni.cpp:86:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         freopen("mootube.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Incorrect 2 ms 596 KB Output isn't correct
3 Incorrect 3 ms 844 KB Output isn't correct
4 Incorrect 3 ms 1108 KB Output isn't correct
5 Incorrect 956 ms 115776 KB Output isn't correct
6 Incorrect 981 ms 129012 KB Output isn't correct
7 Incorrect 797 ms 106412 KB Output isn't correct
8 Incorrect 772 ms 105072 KB Output isn't correct
9 Incorrect 850 ms 111456 KB Output isn't correct
10 Incorrect 867 ms 115372 KB Output isn't correct