Submission #44287

# Submission time Handle Problem Language Result Execution time Memory
44287 2018-03-31T08:58:25 Z khohko None (JOI16_memory2) C++17
0 / 100
2 ms 480 KB
#include <bits/stdc++.h>
//#include "grader.cpp"
#include "Memory2_lib.h"
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define lol long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((lol)(1e9+100))
#define MX ((lol)(4e9+100))
#define ARRS ((lol)(1e6+100))
#define MOD ((lol)(1e9+7))
#define EP ((double)(1e-9))
#define EPS ((double)(1e-8))
#define pb push_back
#define PI ((double)3.141592653)
#define LG 21




//void Answer(int I, int J, int X)
//int Flip(int I, int J)

ll f[300];
ll c[300];

void Solve(int t, int n){

    vector<ll> v;

    for(int i=0; i<2*n; i++)
        f[i]=-1;
    for(int i=0; i<2*n; i++)
        v.pb(i);
    srand(3);
    while(v.size()){
        ll k=rand()%v.size();

        for(int i=0; i<n; i++)c[i]=0;

      //  cout<<k<<endl;
     //   for(int i=0; i<v.size(); i++)
      //      cout<<v[i]<<" - ";
      //  cout<<endl;
        for(int i=0; i<v.size(); i++){
            if(i==k)continue;
            ll p=Flip(v[k],v[i]);
        //    cout<<v[k]<<" "<<v[i]<<" "<<p<<endl;
            f[v[i]]=p;
            c[p]++;
        }
        bool ed=0;
        for(int i=0; i<2*n; i++){
            if(c[i]==1){f[v[k]]=i;ed=1;}
        }
        if(ed)break;
        ll pe=-2;
        for(int i=0; i<2*n; i++)
            if(pe==-2||c[pe]<c[i])pe=i;
       // cout<<pe<<endl;
        vector<ll> b=v;
        v.clear();
        for(auto i:b){
            if(f[i]==pe){
                f[i]=-1;
                v.pb(i);
            }
        }
     //   cout<<pe<<endl;
        if(pe>=0)f[b[k]]=pe;
        //v.pb(k);
        //cout<<v.size()<<endl;
//        cout<<endl;
//        cout<<endl;
//        cout<<endl;
//        cout<<endl;
        if(v.size()==1){
            for(int i=0; i<n; i++){
                if(c[i]==1)pe=i;
            }
            for(int i=0; i<2*n; i++)
                if(i==v[0])f[i]=pe;
            break;
        }
    }
   // cout<<"---"<<endl;
   // for(int i=0; i<2*n; i++){
  //  }
   //cout<<endl;

    for(int i=0; i<2*n; i++)
        for(int j=i+1; j<2*n; j++)
            if(f[i]==f[j])Answer(i,j,f[i]);
}


//
//int main(){
//    #ifdef KHOKHO
//        freopen("in.in","r",stdin);
//        freopen("out.out","w",stdout);
//    #endif // KHOKHO
//    cin>>n;
//
//}

Compilation message

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:49:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0; i<v.size(); i++){
                      ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 480 KB Wrong Answer[3]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 480 KB Wrong Answer[3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 480 KB Wrong Answer[3]
2 Halted 0 ms 0 KB -