Submission #172834

# Submission time Handle Problem Language Result Execution time Memory
172834 2020-01-02T16:36:35 Z mhy908 None (JOI16_memory2) C++14
60 / 100
2 ms 380 KB
#include "Memory2_lib.h"
#include <bits/stdc++.h>
#include <time.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL llinf=9000000000000000000;
const int inf=2000000000;
vector<int> myvec;
vector<pii> ans;
void Solve(int T, int N)
{
	srand((unsigned int)time(NULL));
	for(int i=0; i<N*2; i++)myvec.pb(i);
	while(1){
        if(myvec.size()==2){
            Answer(myvec[0], myvec[1], Flip(myvec[0], myvec[1]));
            return;
        }
        ans.clear();
        int rnd=rand()%myvec.size();
        for(int i=0; i<myvec.size();i++){
            if(i!=rnd)ans.pb(mp(Flip(myvec[i], myvec[rnd]), myvec[i]));
        }
        sort(ans.begin(),ans.end());
        vector<int> temp;
        for(int i=0, j; i<ans.size(); i=j){
            vector<int> now;
            for(j=i; j<ans.size()&&ans[i].F==ans[j].F; j++)now.pb(ans[j].S);
            if(now.size()==2)Answer(now[0], now[1], ans[i].F);
            else{
                now.pb(myvec[rnd]);
                temp=now;
            }
        }
        myvec=temp;
	}
}

Compilation message

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:28:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0; i<myvec.size();i++){
                      ~^~~~~~~~~~~~~
memory2.cpp:33:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0, j; i<ans.size(); i=j){
                         ~^~~~~~~~~~~
memory2.cpp:35:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(j=i; j<ans.size()&&ans[i].F==ans[j].F; j++)now.pb(ans[j].S);
                      ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 276 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 256 KB Wrong Answer[2]
4 Halted 0 ms 0 KB -