답안 #1110973

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110973 2024-11-11T08:09:14 Z modwwe 팀들 (IOI15_teams) C++17
0 / 100
367 ms 57116 KB
//https://www.instagram.com/_modwwe/
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
void phongbeo();
const int inf=1e18;
const int mod2=1e9+7;
const int  mod1=998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    ll a;
    ll b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
struct ie
{
    int a,b,c,d,e;

};

int n,m,s1,s2,s4,s3,sf,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
int  i,s10,s12;
int kk;
int el=29;


ib a[500002];
int dp[1001];
struct fenwick_2d{
 vector<int> bit[500001];
 void fake_upd(int x,int y)
 {
      for(x;x<=n;x+=x&-x)
        bit[x].pb(y);
 }
  void setup()
  {
       for(int i=1;i<=n;i++)
        sort(bit[i].begin(),bit[i].end());
  }
  int get(int x,int y)
  {int s=0;
              for(x;x;x-=x&-x)
                s=s-(lower_bound(bit[x].begin(),bit[x].end(),y)-bit[x].begin()-1),
                s+=bit[x].size();
             return s;
  }
}fen;
vector<int> v;
int c[500002];
int can(int M,int K[])
 {
m=M;
for(auto x:v)
     c[x]=0;
v.clear();
  for(int i=1;i<=m;i++)
     {  l=K[i-1];
         if(!c[l])
          v.pb(l);
      c[l]++;
     }
 sort(v.begin(),v.end());
 v.pb(n+1);
  m=v.size()-1;
  s5=1;
     for(int i=0;i<m;i++)
     {
         s4=fen.get(v[i],v[i]);
         s9=s4;
         s10=0;
         bool de=0;
          for(int j=i;j<m;j++)
          {
               s8=fen.get(v[i],v[j+1]);
               s9=s9-s8-dp[j];
               s10+=dp[j];
                if(s4-s8-s10>=v[i]*c[v[i]])
                {
                     s1=s4-s8-s10-v[i]*c[v[i]];
dp[j]+=s9-s1;
de=1;
                      break;
                }
                else
                {
                  dp[j]+=s9;
                }
                s9=s8;
          }
          if(!de){s5=0; break;}
     }
     for(int i=0;i<m;i++)
         dp[i]=0;
return s5;
 }
 void init(int N, int A[], int B[])
{
    n=N;
    for(int i=0;i<n;i++)
    fen.fake_upd(A[i],B[i]);
}

Compilation message

teams.cpp:19:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   19 | const int inf=1e18;
      |               ^~~~
teams.cpp: In member function 'void fenwick_2d::fake_upd(int, int)':
teams.cpp:58:11: warning: statement has no effect [-Wunused-value]
   58 |       for(x;x<=n;x+=x&-x)
      |           ^
teams.cpp: In member function 'void fenwick_2d::setup()':
teams.cpp:63:16: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   63 |        for(int i=1;i<=n;i++)
      |                ^
teams.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
teams.cpp: In member function 'int fenwick_2d::get(int, int)':
teams.cpp:68:19: warning: statement has no effect [-Wunused-value]
   68 |               for(x;x;x-=x&-x)
      |                   ^
teams.cpp:69:20: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   69 |                 s=s-(lower_bound(bit[x].begin(),bit[x].end(),y)-bit[x].begin()-1),
      |                   ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
teams.cpp:70:32: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   70 |                 s+=bit[x].size();
      |                                ^
teams.cpp: In function 'int can(int, int*)':
teams.cpp:82:11: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   82 |   for(int i=1;i<=m;i++)
      |           ^
teams.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
teams.cpp:90:13: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   90 |   m=v.size()-1;
      |     ~~~~~~~~^~
teams.cpp:92:14: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   92 |      for(int i=0;i<m;i++)
      |              ^
teams.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
teams.cpp:118:14: warning: declaration of 'i' shadows a global declaration [-Wshadow]
  118 |      for(int i=0;i<m;i++)
      |              ^
teams.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:125:13: warning: declaration of 'i' shadows a global declaration [-Wshadow]
  125 |     for(int i=0;i<n;i++)
      |             ^
teams.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 14672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 21316 KB Output is correct
2 Correct 27 ms 21316 KB Output is correct
3 Correct 27 ms 21328 KB Output is correct
4 Correct 32 ms 21828 KB Output is correct
5 Incorrect 20 ms 21284 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 21796 KB Output is correct
2 Correct 36 ms 21688 KB Output is correct
3 Incorrect 74 ms 24800 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 183 ms 51196 KB Output is correct
2 Correct 193 ms 51236 KB Output is correct
3 Incorrect 367 ms 57116 KB Output isn't correct
4 Halted 0 ms 0 KB -