Submission #360167

# Submission time Handle Problem Language Result Execution time Memory
360167 2021-01-27T15:18:52 Z neki Tenis (COCI20_tenis) C++14
80 / 110
84 ms 4076 KB
#include <bits/stdc++.h>
#define ll int
#define loop(i, a, b) for(ll i=a;i<b;i++)
#define pool(i, a, b) for(ll i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 100100
#define par pair<ll, ll>
#define ld long double
#define mod 1000000007
ll per[mn][3], inv[mn][3];
ll cnt[9][3];
void create(ll ind, ll coc){
    loop(i, 1, 9){
        ll zmgpol=-1;
        loop(pol, 0, 3) if(i&(1<<pol)  and (zmgpol==-1 or inv[ind][pol]<inv[ind][zmgpol])) zmgpol=pol;
        cnt[i][zmgpol]+=coc;
    }
}
ll vis[mn];
ll cntpol[3], cntpla[mn];
int main() {
    ll n;cin >> n;
    loop(pol, 0, 3){
        loop(i, 0, n){
            sc("%d", &per[i][pol]);per[i][pol]--;
            inv[per[i][pol]][pol]=i;
        }
    }
    loop(i, 0, n) create(i, 1);
    ll ost=n;
    loop(i, 0, n){
        map<ll, ll> sce;
        loop(pol, 0, 3) if(!vis[per[i][pol]])sce[per[i][pol]]+=(1<<pol);
        fore(v, sce) create(v.fi, -1), --ost, vis[v.fi]=1;
        
        fore(v, sce){
            cntpla[v.fi]+=ost;
            loop(pol, 0, 3) cntpol[pol]+=cnt[v.se][pol];
        }
        
        fore(v, sce) fore(u, sce) if(v.fi<u.fi){
            ll kdo=-1, zmgpol=-1;
            loop(pol, 0, 3){
                
                if(((1<<pol) & v.se) and (kdo==-1 or inv[u.fi][pol]<inv[kdo][zmgpol])) zmgpol=pol, kdo=u.fi;
                if(((1<<pol) & u.se) and (kdo==-1 or inv[v.fi][pol]<inv[kdo][zmgpol])) zmgpol=pol, kdo=v.fi;
            }
            
            //cout << v.fi <<u.fi << kdo<<endl;
            ++cntpol[zmgpol];
            ++cntpla[(kdo==v.fi) ? u.fi:v.fi];
        }
    }
    
    loop(i, 0, 3) cout << cntpol[i]<<" ";cout << endl;
    loop(i, 0, n) cout << cntpla[i]<<" ";cout<<endl;
}

Compilation message

tenis.cpp: In function 'int main()':
tenis.cpp:3:23: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    3 | #define loop(i, a, b) for(ll i=a;i<b;i++)
      |                       ^~~
tenis.cpp:67:5: note: in expansion of macro 'loop'
   67 |     loop(i, 0, 3) cout << cntpol[i]<<" ";cout << endl;
      |     ^~~~
tenis.cpp:67:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   67 |     loop(i, 0, 3) cout << cntpol[i]<<" ";cout << endl;
      |                                          ^~~~
tenis.cpp:3:23: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    3 | #define loop(i, a, b) for(ll i=a;i<b;i++)
      |                       ^~~
tenis.cpp:68:5: note: in expansion of macro 'loop'
   68 |     loop(i, 0, n) cout << cntpla[i]<<" ";cout<<endl;
      |     ^~~~
tenis.cpp:68:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   68 |     loop(i, 0, n) cout << cntpla[i]<<" ";cout<<endl;
      |                                          ^~~~
tenis.cpp:37:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   37 |             sc("%d", &per[i][pol]);per[i][pol]--;
      |               ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 28 ms 1772 KB Output is correct
6 Correct 45 ms 2540 KB Output is correct
7 Correct 58 ms 3308 KB Output is correct
8 Correct 71 ms 4076 KB Output is correct
9 Partially correct 70 ms 4076 KB Partially correct
10 Partially correct 84 ms 4008 KB Partially correct