제출 #1042174

#제출 시각아이디문제언어결과실행 시간메모리
1042174XJP12Unscrambling a Messy Bug (IOI16_messy)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; typedef vector<int> vi; vector<string> bug; int x1=2; int z1=7; bool check_element(string x){ for(int i=0; i<(int)bug.size(); i++){ if(bug[i]==x)return true; } return false; } void compile_set(){ for(int i=0; i<(int)bug.size(); i++){ swap(bug[i][x1], bug[i][z1]); //cout<<bug[i]<<endl; } } void add_element(string x){ bug.push_back(x); } vi restore_permutation(int n, int w, int r){ add_element("10101010"); add_element("10010010"); add_element("01001001"); add_element("10000001"); compile_set(); string s; vi ans(n); int a=0,b=0; if(!check_element("10101010")){ s="10101010"; for(int i=0; i<n; i+=2){ for(int j=1; j<n; j+=2){ string t=s; swap(t[i],t[j]); if(check_element(t)){ a=i; b=j; break; } } } }else{ if(!check_element("10010010")){ s="10010010"; for(int i=0; i<n; i+=3){ for(int j=1; j<n; j++){ if(j%3==0) j++; string t=s; swap(t[i],t[j]); if(check_element(t)){ a=i; b=j; break; } } } }else{ if(!check_element("01001001")){ s="01001001"; for(int i=1; i<n; i+=3){ for(int j=0; j<n; j++){ if(j%3==1) j++; string t=s; swap(t[i],t[j]); if(check_element(t)){ a=i; b=j; break; } } } }else{ s="10000001"; for(int i=0; i<n; i+=7){ for(int j=1; j<n-1; j++){ string t=s; swap(t[i],t[j]); // cout<<t<<" a"<<endl; if(check_element(t)){ a=i; b=j; break; } } } } } } for(int i=0; i<n; i++){ ans[i]=i; if(ans[i]==a){ ans[i]=b; continue; } if(ans[i]==b){ ans[i]=a; continue; } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/cc3TLppK.o: in function `check_element(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x950): multiple definition of `check_element(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/ccxnYTUJ.o:messy.cpp:(.text+0xc0): first defined here
/usr/bin/ld: /tmp/cc3TLppK.o: in function `add_element(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0xad0): multiple definition of `add_element(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/ccxnYTUJ.o:messy.cpp:(.text+0x1d0): first defined here
/usr/bin/ld: /tmp/cc3TLppK.o: in function `compile_set()':
grader.cpp:(.text+0xb30): multiple definition of `compile_set()'; /tmp/ccxnYTUJ.o:messy.cpp:(.text+0x150): first defined here
collect2: error: ld returned 1 exit status