#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define all(x) x.begin(),x.end()
typedef long long ll;
#define INF 99999999999999
#define pb push_back
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
A.pb(0);
vector<int> C(M + 1);
vector<vector<int>>vis(M+1);
vector<int>sw(M+1,0);
ll idx=0;
vector<int> X, Y;
C[0]=A[0];
for(int i=0;i<N;i++)
vis[A[i]].pb(i);
for(int i=1;i<=M;i++)
{
if(!vis[i].size())
continue;
if(vis[i].size()==1)
{
C[i]=A[vis[i][0]+1];
continue;
}
ll j=0;
while((1<<j)<vis[i].size())
j++;
ll start=idx;
C[i]=-(idx+1);
X.pb(-(idx+1));
Y.pb(-(idx+1));
queue<pair<pair<int,int>,pair<int,int>>>q;
q.push({{1,idx},{0,1}});
idx++;
while(!q.empty())
{
ll d=q.front().F.F,id=q.front().F.S;
ll l=q.front().S.F,r=q.front().S.S;
q.pop();
if(j==d)
{
if(l<vis[i].size()-1);
X[id]=A[vis[i][l]+1];
if(r<vis[i].size()-1)
Y[id]=A[vis[i][r]+1];
if(r==(1<<j))
Y[idx]=A[vis[i][vis[i].size()-1]+1];
continue;
}
d++;
X[id]=-(idx+1);
Y[id]=-(idx+2);
X.pb(-(start+1));
Y.pb(-(start+1));
q.push({{d,idx},{l,l+(1<<d)}});
idx++;
X.pb(-(start+1));
Y.pb(-(start+1));
q.push({{d,idx},{r,r+(1<<d)}});
idx++;
}
}
answer(C, X, Y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:35:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | while((1<<j)<vis[i].size())
| ~~~~~~^~~~~~~~~~~~~~
doll.cpp:55:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | if(l<vis[i].size()-1);
| ~^~~~~~~~~~~~~~~~
doll.cpp:55:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
55 | if(l<vis[i].size()-1);
| ^~
doll.cpp:56:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
56 | X[id]=A[vis[i][l]+1];
| ^
doll.cpp:57:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | if(r<vis[i].size()-1)
| ~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
25 ms |
6712 KB |
Output is correct |
3 |
Correct |
19 ms |
5432 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
8 ms |
4180 KB |
Output is correct |
6 |
Correct |
24 ms |
8064 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
25 ms |
6712 KB |
Output is correct |
3 |
Correct |
19 ms |
5432 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
8 ms |
4180 KB |
Output is correct |
6 |
Correct |
24 ms |
8064 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Incorrect |
35 ms |
7472 KB |
wrong motion |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
25 ms |
6712 KB |
Output is correct |
3 |
Correct |
19 ms |
5432 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
8 ms |
4180 KB |
Output is correct |
6 |
Correct |
24 ms |
8064 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Incorrect |
35 ms |
7472 KB |
wrong motion |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |