保存されている過去のバージョンの一覧

2019年09月16日01時49分15秒

Codeforces Round #585 DIV2 C問題 - Swap Letters

Source

Codeforces Round #585 DIV2 C問題 (1750pt)
Problem description

問題概要

省略

解法

省略

cLayversion 20190914-1)のコード

C++に変換後のコードはこちら

//no-unlocked
int N;
char S[200002], T[200002];

int ab[2d5], absz;
int ba[2d5], basz;

int ress, res1[2d5], res2[2d5];

{
  rd(N,S,T);
  rep(i,N){
    if(S[i]=='a' && T[i]=='b') ab[absz++] = i;
    if(S[i]=='b' && T[i]=='a') ba[basz++] = i;
  }

  if( (absz + basz)%2 ) wt(-1), return 0;

  while(absz >= 2){
    res1[ress] = ab[--absz];
    res2[ress++] = ab[--absz];
  }

  while(basz >= 2){
    res1[ress] = ba[--basz];
    res2[ress++] = ba[--basz];
  }

  if(absz && basz){
    res1[ress] = ab[0];
    res2[ress++] = ab[0];
    res1[ress] = ab[0];
    res2[ress++] = ba[0];
  }

  wt(ress);
  rep(i,ress) wt(res1[i]+1, res2[i]+1);
}

Current time: 2024年03月29日22時44分25秒
Last modified: 2019年09月16日01時49分15秒 (by laycrs)
Tags: Competitive_Programming_Incomplete Codeforces CF585 CF_Div2_C
トップページに戻る

Logged in as: unknown user (not login)

ログイン: