답안 #1006188

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006188 2024-06-23T14:10:25 Z m5588ohammed Data Transfer (IOI19_transfer) C++14
0 / 100
5 ms 5396 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> get_attachment(vector <int> source) {
    int cnt=0,sum=0,k;
    for(int i=1;i<=source.size();i++){
        if(source[i-1]==1){
            sum++;
            cnt^=i;
        }
    }
    vector <int> ans=source;
    k=sum%2;
    while(cnt!=0){
        ans.push_back(cnt%2);
        cnt/=2;
    }
    ans.push_back(k);
    return ans;
}
 
vector<int> retrieve(vector<int> data) {
    int cnt=0,sum=0,k=data[data.size()-1],num=0;
    int n = (data.size() > 255 ? 255 : 63);
    for(int i=1;i<=n;i++){
        if(data[i-1]==1){
            sum++;
            cnt^=i;
        }
    }
    
    for(int i=n;i<data.size()-1;i++) num+=data[i]*(1<<(i-n));
    if(sum%2!=k&&cnt!=num) data[(cnt^num)-1]^=1;
    
    vector <int> ans;
    for(int i=0;i<n;i++) ans.push_back(data[i]);
    
    return ans;
 
}
// int main(){
//     char c;
//     vector <int> ans;
//     for(int i=0;i<63;i++){
//         cin>>c;
//         if(c=='1') ans.push_back(1);
//         else ans.push_back(0);
//     }
//     ans=get_attachment(ans);
//     for(int i:ans) cout<<i<<" ";
// }

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:5:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |     for(int i=1;i<=source.size();i++){
      |                 ~^~~~~~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=n;i<data.size()-1;i++) num+=data[i]*(1<<(i-n));
      |                 ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 1296 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 5396 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -