답안 #456296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
456296 2021-08-06T11:15:09 Z urosk Xor Sort (eJOI20_xorsort) C++14
0 / 100
1 ms 320 KB
///sat
#include <chrono>
using namespace std::chrono;
#define vremestart auto start = high_resolution_clock::now();
#define vremeend auto stop = high_resolution_clock::now();
#define vremeispis auto duration = duration_cast<microseconds>(stop - start); cout << duration.count() << endl;
///sat
#define here cerr<<"---------------------------\n"
#define popcount(x) __builtin_popcount(x) ///broj bitova
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define th third
#define fo fourth
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
using namespace std;
void setIO(string inoutname)
{
	freopen((inoutname+".in").c_str(),"r",stdin);
    	freopen((inoutname+".out").c_str(),"w",stdout);
}

ll gcd(ll a, ll b)
{
   if(b==0) return a;
   if(a==0) return b;
   if(a>=b)  return gcd(a%b,b);
   return  gcd(a,b%a);
}
#define maxn 1005
ll n,s;
ll a[maxn][25];
void xor_(ll i,ll j){
    for(ll k = 0;k<25;k++){
        a[i][k]^=a[j][k];
    }
    return;
}

void tc(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
    cin >> n >> s;
    ll x;
    for(ll i = 1;i<=n;i++){
        cin >> x;
        ll j = 0;
        while(x>0){
            ll f = x%2;
            a[i][j] = f;
            j++;
            x/=2;
        }
    }
    /*for(ll i = 1;i<=n;i++){
        for(ll j = 19;j>=0;j--) cout<<a[i][j];
        cout<<endl;
    }*/
    vector<pll> ans;
    for(ll i = 19;i>=0;i--){
        for(ll j = 1;j<n;j++){
            if(a[j][i]==1){
                if(a[j+1][i]==1){
                    xor_(j,j+1);
                    ans.pb({j,j+1});
                }else{
                    xor_(j+1,j);
                    ans.pb({j+1,j});
                }
            }
        }
    }
    cout<<sz(ans)<<endl;
    for(pll p : ans){
        cout<<p.fi<< " "<<p.sc<<endl;
    }
    /*for(ll i = 1;i<=n;i++){
        for(ll j = 19;j>=0;j--) cout<<a[i][j];
        cout<<endl;
    }*/
}
int main(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
	//setIO("lol");
	int t; t = 1;
	while(t--){
		tc();
	}
	return 0;
}

Compilation message

xorsort.cpp: In function 'void setIO(std::string)':
xorsort.cpp:32:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  freopen((inoutname+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xorsort.cpp:33:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |      freopen((inoutname+".out").c_str(),"w",stdout);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 320 KB Not sorted
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 320 KB Not sorted
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Not sorted
2 Halted 0 ms 0 KB -