Please sign in first.
Submission #58273888
Source Code Expand
#define DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}
// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
public:
template<typename T>
_Debug& operator,(T val) {
cout << val << endl;
return *this;
}
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif
// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back
// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;
// ---------- END OF TEMPLATE ----------
int A[100];
deque<int> Q1,Q2;
int main() {
int i;
int N;
scanf("%d",&N);
for (i = 0; i < N; i++) {
scanf("%d",&A[i]);
Q1.pb(i);
Q2.pb(i);
}
string S,T;
for (i = 0; i < N; i++) S += '0',T += '1';
while (!Q1.empty()) {
for (i = 1; i < Q1.size(); i++) {
if (A[Q1[i]] == A[Q1[0]]) break;
}
if (i == Q1.size()) {
while (Q2[0] != Q1[0]) {
S += '1',T += '1';
Q2.pb(Q2[0]),Q2.pop_front();
}
S += '1',T += '0';
Q1.pop_front(),Q2.pop_front();
}
else {
int p = i;
while (Q2[0] != Q1[p]) {
S += '1',T += '1';
Q2.pb(Q2[0]),Q2.pop_front();
}
S += '1',T += '0';
Q1[p] = Q1[0];
Q1.pop_front(),Q2.pop_front();
}
}
cout << S.size() << endl;
cout << S << endl << T << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - 01 Graph Construction |
| User | duality |
| Language | C++ 20 (gcc 12.2) |
| Score | 900 |
| Code Size | 2681 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3896 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:73:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::deque<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
73 | for (i = 1; i < Q1.size(); i++) {
| ~~^~~~~~~~~~~
Main.cpp:76:15: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::deque<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
76 | if (i == Q1.size()) {
| ~~^~~~~~~~~~~~
Main.cpp:63:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
63 | scanf("%d",&N);
| ~~~~~^~~~~~~~~
Main.cpp:65:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
65 | scanf("%d",&A[i]);
| ~~~~~^~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 900 / 900 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt |
| All | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt, 01-032.txt, 01-033.txt, 01-034.txt, 01-035.txt, 01-036.txt, 01-037.txt, 01-038.txt, 01-039.txt, 01-040.txt, 01-041.txt, 01-042.txt, 01-043.txt, 01-044.txt, 01-045.txt, 01-046.txt, 01-047.txt, 01-048.txt, 01-049.txt, 01-050.txt, 01-051.txt, 01-052.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-001.txt | AC | 1 ms | 3620 KiB |
| 00-sample-002.txt | AC | 1 ms | 3884 KiB |
| 00-sample-003.txt | AC | 1 ms | 3764 KiB |
| 00-sample-004.txt | AC | 1 ms | 3628 KiB |
| 01-001.txt | AC | 1 ms | 3664 KiB |
| 01-002.txt | AC | 1 ms | 3704 KiB |
| 01-003.txt | AC | 1 ms | 3700 KiB |
| 01-004.txt | AC | 1 ms | 3896 KiB |
| 01-005.txt | AC | 1 ms | 3704 KiB |
| 01-006.txt | AC | 1 ms | 3668 KiB |
| 01-007.txt | AC | 1 ms | 3780 KiB |
| 01-008.txt | AC | 1 ms | 3504 KiB |
| 01-009.txt | AC | 1 ms | 3760 KiB |
| 01-010.txt | AC | 1 ms | 3512 KiB |
| 01-011.txt | AC | 1 ms | 3708 KiB |
| 01-012.txt | AC | 1 ms | 3712 KiB |
| 01-013.txt | AC | 1 ms | 3712 KiB |
| 01-014.txt | AC | 1 ms | 3704 KiB |
| 01-015.txt | AC | 1 ms | 3512 KiB |
| 01-016.txt | AC | 1 ms | 3896 KiB |
| 01-017.txt | AC | 1 ms | 3520 KiB |
| 01-018.txt | AC | 1 ms | 3708 KiB |
| 01-019.txt | AC | 1 ms | 3892 KiB |
| 01-020.txt | AC | 1 ms | 3708 KiB |
| 01-021.txt | AC | 1 ms | 3696 KiB |
| 01-022.txt | AC | 1 ms | 3708 KiB |
| 01-023.txt | AC | 1 ms | 3712 KiB |
| 01-024.txt | AC | 1 ms | 3632 KiB |
| 01-025.txt | AC | 1 ms | 3896 KiB |
| 01-026.txt | AC | 1 ms | 3632 KiB |
| 01-027.txt | AC | 1 ms | 3692 KiB |
| 01-028.txt | AC | 1 ms | 3620 KiB |
| 01-029.txt | AC | 1 ms | 3572 KiB |
| 01-030.txt | AC | 1 ms | 3768 KiB |
| 01-031.txt | AC | 1 ms | 3884 KiB |
| 01-032.txt | AC | 1 ms | 3664 KiB |
| 01-033.txt | AC | 1 ms | 3700 KiB |
| 01-034.txt | AC | 1 ms | 3704 KiB |
| 01-035.txt | AC | 1 ms | 3684 KiB |
| 01-036.txt | AC | 1 ms | 3700 KiB |
| 01-037.txt | AC | 1 ms | 3884 KiB |
| 01-038.txt | AC | 1 ms | 3696 KiB |
| 01-039.txt | AC | 1 ms | 3700 KiB |
| 01-040.txt | AC | 1 ms | 3708 KiB |
| 01-041.txt | AC | 1 ms | 3684 KiB |
| 01-042.txt | AC | 1 ms | 3768 KiB |
| 01-043.txt | AC | 1 ms | 3568 KiB |
| 01-044.txt | AC | 1 ms | 3704 KiB |
| 01-045.txt | AC | 1 ms | 3708 KiB |
| 01-046.txt | AC | 1 ms | 3884 KiB |
| 01-047.txt | AC | 1 ms | 3724 KiB |
| 01-048.txt | AC | 1 ms | 3632 KiB |
| 01-049.txt | AC | 1 ms | 3648 KiB |
| 01-050.txt | AC | 1 ms | 3640 KiB |
| 01-051.txt | AC | 1 ms | 3708 KiB |
| 01-052.txt | AC | 1 ms | 3716 KiB |