답안 #388472

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
388472 2021-04-11T16:05:52 Z fadi57 도서관 (JOI18_library) C++14
0 / 100
337 ms 840 KB
#include <cstdio>
#include<bits/stdc++.h>
#include <vector>
#include "library.h"
//#include "grader.cpp"
using namespace std;
const int mx=10000;
int l[mx];
int r[mx];
vector<int>adj[mx];
int vis[mx];
void Solve(int N)
{
	vector<int> M(N);

	for(int i = 0; i < N; i++) {
		M[i] = 0;
	}
	memset(l,-1,mx);
	memset(r,-1,mx);
	map<int,int>mp;
   for(int i=0;i<N;i++){
    M[i]=1;
    for(int  j=i+1;j<N;j++){

        M[j]=1;
        int z=Query(M);
        if(z==1){
          adj[i].push_back(j);
          adj[j].push_back(i);
        }
        M[j]=0;
     }
     M[i]=0;
   }
   int left=-1;int right=-1;
   int s;
     for(int i=0;i<N;i++){
     if(adj[i].size()==1){

      s=i;break;
     }
   }

vector <int> res(N);
 queue<int>q;
 q.push(s);
  vis[s]=1;
 res[0]=s;
 int i=0;

 while(q.size()){

    int me=q.front();

    q.pop();
   // while(q.size()){q.pop();}
    res[i]=me+1;
    vis[me]=1;
    for(auto it:adj[me]){
        if(vis[it]){continue;}
        q.push(it);
        vis[it]=1;
        break;
    }
    i++;
 }
 /*
for(int i=0;i<N;i++){cout<<res[i]<<" ";}
    for(int i=0;i<N;i++){
        for(auto it:adj[i]){
            cout<<it<<" ";
        }
        cout<<"\n";

    }*/

	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:19:16: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
   19 |  memset(l,-1,mx);
      |                ^
library.cpp:20:16: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
   20 |  memset(r,-1,mx);
      |                ^
library.cpp:36:8: warning: unused variable 'left' [-Wunused-variable]
   36 |    int left=-1;int right=-1;
      |        ^~~~
library.cpp:36:20: warning: unused variable 'right' [-Wunused-variable]
   36 |    int left=-1;int right=-1;
      |                    ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 308 ms 540 KB # of queries: 18336
2 Correct 203 ms 548 KB # of queries: 18145
3 Correct 330 ms 544 KB # of queries: 19900
4 Correct 337 ms 456 KB # of queries: 19900
5 Correct 297 ms 576 KB # of queries: 19900
6 Correct 332 ms 632 KB # of queries: 19900
7 Correct 322 ms 540 KB # of queries: 19900
8 Correct 314 ms 576 KB # of queries: 18528
9 Correct 307 ms 556 KB # of queries: 19701
10 Correct 143 ms 460 KB # of queries: 8256
11 Runtime error 1 ms 840 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 308 ms 540 KB # of queries: 18336
2 Correct 203 ms 548 KB # of queries: 18145
3 Correct 330 ms 544 KB # of queries: 19900
4 Correct 337 ms 456 KB # of queries: 19900
5 Correct 297 ms 576 KB # of queries: 19900
6 Correct 332 ms 632 KB # of queries: 19900
7 Correct 322 ms 540 KB # of queries: 19900
8 Correct 314 ms 576 KB # of queries: 18528
9 Correct 307 ms 556 KB # of queries: 19701
10 Correct 143 ms 460 KB # of queries: 8256
11 Runtime error 1 ms 840 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -