답안 #1073239

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073239 2024-08-24T10:51:30 Z Faisal_Saqib 자동 인형 (IOI18_doll) C++17
85.553 / 100
71 ms 12868 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define vll vector<int>
#define ll int
void answer(std::vector<int> C, std::vector<int> X, std::vector<int> Y);
#define REP(i, n) for (int i = 0; i < (n); i++)
int generate(const vector<int>& after, int& S, vector<int>& X, vector<int>& Y) { const int size = after.size(); if (size == 0) { return 0; } else if (size == 1) { return after[0]; } else { int k = 1, K=0; while (k < size) { k *= 2; K++; } vector<int> revbits(k), go(k); REP(j, k) { revbits[j] = revbits[j/2]/2 | ((j&1) << K-1); } const int id = --S; REP(lev, K-1) { REP(j, 1<<lev) { if ((j << K-lev) + (1 << K-lev) <= (k-size)) {  } else if ((j << K-lev) + (1 << K-lev-1) <= (k-size)) { X.push_back(id); Y.push_back(--S); } else { X.push_back(--S); Y.push_back(--S); } } } int ptr = 0; REP(j, k) { if (revbits[j] < (k-size)) { ; } else { go[ revbits[j] ] = after[ptr++]; } }  REP(j, k/2) { if (2*j + 2 <= (k-size)) { } else if (2*j + 1 <= (k-size)) { X.push_back(id); Y.push_back(go[2*j+1]); } else { X.push_back(go[2*j]); Y.push_back(go[2*j+1]); } } return id; } }
void create_circuit(int m, std::vector<int> A)
{
	A.push_back(0); int N = A.size(),M=m;
	vector<int> X,Y,C(m+1);
	vector<vector<int> > after(M+1);
	REP(i, N){ after[A[i]].push_back(A[(i+1) % N]);}
	int S = 0;
	REP(i, M+1) { C[i] = generate(after[i], S, X, Y); }
	answer(C,X,Y);
}

Compilation message

doll.cpp: In function 'int generate(const std::vector<int>&, int&, std::vector<int>&, std::vector<int>&)':
doll.cpp:8:324: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    8 | int generate(const vector<int>& after, int& S, vector<int>& X, vector<int>& Y) { const int size = after.size(); if (size == 0) { return 0; } else if (size == 1) { return after[0]; } else { int k = 1, K=0; while (k < size) { k *= 2; K++; } vector<int> revbits(k), go(k); REP(j, k) { revbits[j] = revbits[j/2]/2 | ((j&1) << K-1); } const int id = --S; REP(lev, K-1) { REP(j, 1<<lev) { if ((j << K-lev) + (1 << K-lev) <= (k-size)) {  } else if ((j << K-lev) + (1 << K-lev-1) <= (k-size)) { X.push_back(id); Y.push_back(--S); } else { X.push_back(--S); Y.push_back(--S); } } } int ptr = 0; REP(j, k) { if (revbits[j] < (k-size)) { ; } else { go[ revbits[j] ] = after[ptr++]; } }  REP(j, k/2) { if (2*j + 2 <= (k-size)) { } else if (2*j + 1 <= (k-size)) { X.push_back(id); Y.push_back(go[2*j+1]); } else { X.push_back(go[2*j]); Y.push_back(go[2*j+1]); } } return id; } }
      |                                                                                                                                                                                                                                                                                                                                   ~^~
doll.cpp:8:395: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    8 | int generate(const vector<int>& after, int& S, vector<int>& X, vector<int>& Y) { const int size = after.size(); if (size == 0) { return 0; } else if (size == 1) { return after[0]; } else { int k = 1, K=0; while (k < size) { k *= 2; K++; } vector<int> revbits(k), go(k); REP(j, k) { revbits[j] = revbits[j/2]/2 | ((j&1) << K-1); } const int id = --S; REP(lev, K-1) { REP(j, 1<<lev) { if ((j << K-lev) + (1 << K-lev) <= (k-size)) {  } else if ((j << K-lev) + (1 << K-lev-1) <= (k-size)) { X.push_back(id); Y.push_back(--S); } else { X.push_back(--S); Y.push_back(--S); } } } int ptr = 0; REP(j, k) { if (revbits[j] < (k-size)) { ; } else { go[ revbits[j] ] = after[ptr++]; } }  REP(j, k/2) { if (2*j + 2 <= (k-size)) { } else if (2*j + 1 <= (k-size)) { X.push_back(id); Y.push_back(go[2*j+1]); } else { X.push_back(go[2*j]); Y.push_back(go[2*j+1]); } } return id; } }
      |                                                                                                                                                                                                                                                                                                                                                                                                          ~^~~~
doll.cpp:8:410: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    8 | int generate(const vector<int>& after, int& S, vector<int>& X, vector<int>& Y) { const int size = after.size(); if (size == 0) { return 0; } else if (size == 1) { return after[0]; } else { int k = 1, K=0; while (k < size) { k *= 2; K++; } vector<int> revbits(k), go(k); REP(j, k) { revbits[j] = revbits[j/2]/2 | ((j&1) << K-1); } const int id = --S; REP(lev, K-1) { REP(j, 1<<lev) { if ((j << K-lev) + (1 << K-lev) <= (k-size)) {  } else if ((j << K-lev) + (1 << K-lev-1) <= (k-size)) { X.push_back(id); Y.push_back(--S); } else { X.push_back(--S); Y.push_back(--S); } } } int ptr = 0; REP(j, k) { if (revbits[j] < (k-size)) { ; } else { go[ revbits[j] ] = after[ptr++]; } }  REP(j, k/2) { if (2*j + 2 <= (k-size)) { } else if (2*j + 1 <= (k-size)) { X.push_back(id); Y.push_back(go[2*j+1]); } else { X.push_back(go[2*j]); Y.push_back(go[2*j+1]); } } return id; } }
      |                                                                                                                                                                                                                                                                                                                                                                                                                         ~^~~~
doll.cpp:8:450: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    8 | int generate(const vector<int>& after, int& S, vector<int>& X, vector<int>& Y) { const int size = after.size(); if (size == 0) { return 0; } else if (size == 1) { return after[0]; } else { int k = 1, K=0; while (k < size) { k *= 2; K++; } vector<int> revbits(k), go(k); REP(j, k) { revbits[j] = revbits[j/2]/2 | ((j&1) << K-1); } const int id = --S; REP(lev, K-1) { REP(j, 1<<lev) { if ((j << K-lev) + (1 << K-lev) <= (k-size)) {  } else if ((j << K-lev) + (1 << K-lev-1) <= (k-size)) { X.push_back(id); Y.push_back(--S); } else { X.push_back(--S); Y.push_back(--S); } } } int ptr = 0; REP(j, k) { if (revbits[j] < (k-size)) { ; } else { go[ revbits[j] ] = after[ptr++]; } }  REP(j, k/2) { if (2*j + 2 <= (k-size)) { } else if (2*j + 1 <= (k-size)) { X.push_back(id); Y.push_back(go[2*j+1]); } else { X.push_back(go[2*j]); Y.push_back(go[2*j+1]); } } return id; } }
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ~^~~~
doll.cpp:8:469: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    8 | int generate(const vector<int>& after, int& S, vector<int>& X, vector<int>& Y) { const int size = after.size(); if (size == 0) { return 0; } else if (size == 1) { return after[0]; } else { int k = 1, K=0; while (k < size) { k *= 2; K++; } vector<int> revbits(k), go(k); REP(j, k) { revbits[j] = revbits[j/2]/2 | ((j&1) << K-1); } const int id = --S; REP(lev, K-1) { REP(j, 1<<lev) { if ((j << K-lev) + (1 << K-lev) <= (k-size)) {  } else if ((j << K-lev) + (1 << K-lev-1) <= (k-size)) { X.push_back(id); Y.push_back(--S); } else { X.push_back(--S); Y.push_back(--S); } } } int ptr = 0; REP(j, k) { if (revbits[j] < (k-size)) { ; } else { go[ revbits[j] ] = after[ptr++]; } }  REP(j, k/2) { if (2*j + 2 <= (k-size)) { } else if (2*j + 1 <= (k-size)) { X.push_back(id); Y.push_back(go[2*j+1]); } else { X.push_back(go[2*j]); Y.push_back(go[2*j+1]); } } return id; } }
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 17 ms 6744 KB Output is correct
3 Correct 17 ms 5676 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 6 ms 3932 KB Output is correct
6 Correct 27 ms 8404 KB Output is correct
7 Correct 0 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 17 ms 6744 KB Output is correct
3 Correct 17 ms 5676 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 6 ms 3932 KB Output is correct
6 Correct 27 ms 8404 KB Output is correct
7 Correct 0 ms 600 KB Output is correct
8 Correct 30 ms 8200 KB Output is correct
9 Correct 33 ms 9548 KB Output is correct
10 Correct 52 ms 12868 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 17 ms 6744 KB Output is correct
3 Correct 17 ms 5676 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 6 ms 3932 KB Output is correct
6 Correct 27 ms 8404 KB Output is correct
7 Correct 0 ms 600 KB Output is correct
8 Correct 30 ms 8200 KB Output is correct
9 Correct 33 ms 9548 KB Output is correct
10 Correct 52 ms 12868 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 53 ms 12364 KB Output is correct
15 Correct 30 ms 7116 KB Output is correct
16 Correct 44 ms 10304 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 54 ms 12152 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 24 ms 7360 KB Output is correct
3 Correct 26 ms 7136 KB Output is correct
4 Correct 39 ms 9128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 24 ms 7360 KB Output is correct
3 Correct 26 ms 7136 KB Output is correct
4 Correct 39 ms 9128 KB Output is correct
5 Partially correct 59 ms 12868 KB Output is partially correct
6 Partially correct 71 ms 12100 KB Output is partially correct
7 Partially correct 61 ms 12372 KB Output is partially correct
8 Partially correct 51 ms 11592 KB Output is partially correct
9 Partially correct 27 ms 7748 KB Output is partially correct
10 Partially correct 46 ms 11080 KB Output is partially correct
11 Partially correct 40 ms 10560 KB Output is partially correct
12 Partially correct 30 ms 7340 KB Output is partially correct
13 Partially correct 42 ms 7800 KB Output is partially correct
14 Partially correct 43 ms 8068 KB Output is partially correct
15 Partially correct 39 ms 8316 KB Output is partially correct
16 Partially correct 2 ms 600 KB Output is partially correct
17 Partially correct 28 ms 6528 KB Output is partially correct
18 Partially correct 27 ms 7196 KB Output is partially correct
19 Partially correct 26 ms 6528 KB Output is partially correct
20 Partially correct 42 ms 10060 KB Output is partially correct
21 Partially correct 51 ms 9796 KB Output is partially correct
22 Partially correct 37 ms 9792 KB Output is partially correct