QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#114379#4582. Uniform Makerberarchegas#AC ✓3ms9772kbC++171.9kb2023-06-22 00:07:372023-06-22 00:07:40

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-22 00:07:40]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:9772kb
  • [2023-06-22 00:07:37]
  • 提交

answer

#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <random>
#include <bits/stdc++.h>

using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;

ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

#define Unique(v) sort(all(v));v.erase(unique(all(v)),v.end());

const int maxn = 2*100000 + 10;

// const int inf = 1000000000;
// const ll inf = 1000000000000000000LL;

// const ll mod = 1000000007; // 10^9 + 7
// const ll mod = (119 << 23) + 1; // 998244353

int n, m;

string s[maxn];

int cost(vector<int> freq)
{
    int ans = n;

    for(int i = 0 ; i < (int)freq.size() ; i++)
        ans = min( ans , n - freq[i] );

    return ans;
}

void solve(int testcase)
{
    cin >> n >> m;

    for(int i = 1 ; i <= n ; i++)
        cin >> s[i];

    int ans = 0;

    for(int i = 0 ; i < m ; i++)
    {
        vector<int> freq(26, 0);

        for(int j = 1 ; j <= n ; j++)
            freq[ s[j][i] - 'a' ]++;

        ans += cost( freq );
    }

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);  
    cin.tie(NULL);

    int t = 1;
    // cin >> t;

    for(int testcase = 1 ; testcase <= t ; testcase++)
        solve( testcase );
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 9728kb

input:

6 4
calf
palm
book
icpc
ball
room

output:

14

result:

ok single line: '14'

Test #2:

score: 0
Accepted
time: 0ms
memory: 9716kb

input:

3 11
goodluckfor
icpcjakarta
contestants

output:

19

result:

ok single line: '19'

Test #3:

score: 0
Accepted
time: 1ms
memory: 9748kb

input:

5 14
helpiamtrapped
inanincfactory
forthreemonths
withoutfoodand
drinkandshower

output:

49

result:

ok single line: '49'

Test #4:

score: 0
Accepted
time: 1ms
memory: 9676kb

input:

2 1
o
o

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 0ms
memory: 9772kb

input:

40 6
xscwqh
djjjit
rguenl
hhxvjg
tnoyfq
ownyjt
asdzdz
slsbph
rdlksd
jpcjyx
bzaozh
dpgxfk
pozhhl
zkagxn
sihjxn
atqiiy
zwebxg
ilxcnj
ntkrnq
ysxfri
qrowho
dhwaqs
haljan
oxjcnk
dalixq
ahzfrd
cphsor
sykafq
lpzpvz
xarslv
rnqiau
xcolzn
jsuclf
vkoqxx
wqidkz
owqnjx
oodyrv
hzbxda
ceikgy
ohxepx

output:

214

result:

ok single line: '214'

Test #6:

score: 0
Accepted
time: 3ms
memory: 9684kb

input:

61 45
gxpedrilqbjsxgwblbnbmxetlxersnnhizajpmqjazzer
ihrfbypimkhqgxnljylpilzpdjcriqpvrkkazzjlsyqrv
gzoxytcshicdtbagdlgnwueyldicppytywbypzxkujfdt
rerxwaccmqpjgcezwxbhmmdmlnzzlcwbdmhlkgkbrdiws
kqjkaljprbqvxqrsinicvkukhisaotkcnpcsrqayxcrwx
aanykynujzejawnuvsjqfhcnchfacagdbnbfwjeboxuxl
xdifsllnhjbuktkyea...

output:

2485

result:

ok single line: '2485'

Test #7:

score: 0
Accepted
time: 1ms
memory: 9752kb

input:

72 49
mppvddwntczohpfodjzwuietolkuduevzrhtyubtlkdfazogc
zscsvefyvsbhwsktyiqjnjoqnxderweavrbkyudsembqdnovj
mynjgypbhfpveeegkjlpgkdgbmanhzmrsemtxzadeeicphwsj
igcbqvujkorzpaqdkumuvupnczaknpobvkssfguyqrghntgcs
zhbmyxgztyaugdtmnzcjkejeooravumkkfdhuusakuntrceva
eidpemasnvjmddwwnojtnsvzehwspjqkpffieymhjggp...

output:

3207

result:

ok single line: '3207'

Test #8:

score: 0
Accepted
time: 1ms
memory: 9712kb

input:

33 22
bsilkickfqgjfnjbdrtdie
dspzexblehklsoqgasuaiy
rsawkiayvzeerohwdbyupa
xrhcvcyhkjxnibikzyymfz
vyihzvwjxqoihffpnwrytg
ernvlffnoxhwnafqxqizpr
doqehgyvkbpafpwruvgnxv
bvtklcvtmzbwfqzcipeaup
bvbthqbdzervnpunrfelfp
wqisltkqbesoobrphzkgfk
khqoybrznukqcvmfewpzsq
yohlkqerwovtujbvoqgide
umflnhnpfamibqaawo...

output:

635

result:

ok single line: '635'

Test #9:

score: 0
Accepted
time: 3ms
memory: 9652kb

input:

79 90
ksmlllnmnthxulpmivvwbqxsteprtcpsueyllhaclavyjhdxrurfkpdzwaxaemavmgghuyoeevrqkumavmynjfxutv
leavuqnmltcuojumimqwdmxskessutzsquvlyhacntvnjsduhqrzrpdppixvemjemxgtnkoeqncqydiwcynsjviuts
ksmlhnpmntgpulwrnjqfdqhstisrynpmquuhliaqrtohyhecrizzjnipazlvmddvaxxtnylfcsjqkxpwcyqvdrxzyc
lelruqpmntglujwznvqfc...

output:

4765

result:

ok single line: '4765'

Test #10:

score: 0
Accepted
time: 3ms
memory: 9680kb

input:

80 86
mznirypdgjejjgdebcsqnfmwjakrecfanoqxkeasdjcxikjrznhfjnxigmgzkmswgrujgquxrnazusqdfqjozg
pywehnxkqyefeqtevxynsqjejfedglkgsomnsefzlfgdkqidsnhgqjxiaohofagjzjwjmiubdjfjhjcurhuchl
yvatruoklfeueoinmmsczhvgdfovgqpxveyxkexqiyxkiqidqihgrryoxmhgtpealzmtgqnydjmwuzdbahjxyw
glxkryteuyemfqddgmwknkjwdrjigwfhv...

output:

5700

result:

ok single line: '5700'

Test #11:

score: 0
Accepted
time: 3ms
memory: 9756kb

input:

68 97
tvwqmgmylvewycfkyuzhjurughmljtldcvpruvwfoixbaorptjbqszvthrkbphoxnyqvyliqgkbgaujxxqlgfuinhhzzjngfm
blazjgnimsfzcpfzsgsgnmojszmxlufcapejiuxcxcoqichvwvwzknstqjwlvfzeuztbdnudvisjejswcgagfynnbjwnopiff
tqzctklohhxxcdhkkkshhfzpovwsozkobdstcipcnsesdppgoyqhryfwdbqlrhbrotuhuxstigohjiwqhircfaqndmiyjbqhf
...

output:

5738

result:

ok single line: '5738'

Test #12:

score: 0
Accepted
time: 3ms
memory: 9756kb

input:

70 90
olkfdsmscwiudgkrpcbyeueodkgzzsmuzlsjofikpjcnkytvewxhbstpttfcjlexegrnykzrevbtwshgmnuowlkevi
iirotttercrqsjcpljzmoibiebsuwebxmpxsofoxbooxmnfcemnvkapnejjzllvpykvhjwqnlyaoyluddcjoqpuila
owwgfhfrscjmiwkjbrbulkququggzlbvykijefxttzupgusctilhfltoktcxlnsxmgzhgvdvtxifadqkzcdzpfibix
jwrsfsanswddticrbctai...

output:

5235

result:

ok single line: '5235'

Test #13:

score: 0
Accepted
time: 3ms
memory: 9756kb

input:

100 100
ababaabbbbaababbbbaaabaabaaaaabbaabbabbabbbbaaabbbbbaaabaaabababababaaabbabbbbbaaaababaaaaaaabaaabaa
aabbbabbabababbabababaaaabaabbaabbababbbabbbbbaaabbbbaababbabbbaabaaabbabaabbabbbaabbbaaabaabaabbaab
bbabababaaababbabbaaababbaabababbbabaabbbbbaaababbaaabbabaaabaaaaababbaaababababaaaabbabab...

output:

4578

result:

ok single line: '4578'

Test #14:

score: 0
Accepted
time: 3ms
memory: 9764kb

input:

100 100
dftpeaalqzhuzuoxrkkhbyaqndxzortumgjmjdojaoskobvsdugktgerdoprqjtqwkaohhakthlqweypmpqvmtfaipmczbkvlgst
xzyzpsmokvfetzmfzsqbpddftllfatehxjbrgapygjigfukjljchxcjskpyzxqxaymhauiyniyoawzpxtrxcmznobapvifjhjpwd
iysrdibtmwkvypfuwetqcjqhpdobbaxwtrprdpgjwjlhfijscmwthclmzklapeqcfjwsuqspimocrojfywefnvsooj...

output:

9171

result:

ok single line: '9171'

Test #15:

score: 0
Accepted
time: 2ms
memory: 9728kb

input:

2 1
s
u

output:

1

result:

ok single line: '1'

Test #16:

score: 0
Accepted
time: 3ms
memory: 9728kb

input:

100 100
xescvdcxudqumidmdgmnqfbxfviejvftmqviopofscbjyzkiabytowlqsquyhkqhrhpbbabbefvbjtviysgjfgaiucyhcthcbzos
ydnjpfxymdnavjdyoubnffjqukxrzvnrivcjiycfewvbzduwbnywgggweajqurovufxyuuwremmavxhkrvixgkcbicyhrnhvtgqm
lzxuvuvnnvcikhrlbemgqoonynsxozaxavdiunotmkqcfzyywcwtmywcqaerirugbgciwezpnudnjlkiyyaautsjgw...

output:

7883

result:

ok single line: '7883'

Test #17:

score: 0
Accepted
time: 0ms
memory: 9760kb

input:

100 100
axdiqbkcxgwawvubkmufqocdphkwviishvdmmoqnxjpzkdjukmxzdokrwhxucksfmprqukxtqzjoagiuuxkmgcpxcmuktrqmfowk
azafqbkwjgqxwvubkaufqxtiwlkmvisshfdeqttfbjpkddjuemenvokrmhjhyiqfyprqekyzqzjoskgbuxkmbgpwkmukksmkkowl
awdiqbkwrgwxwvujuaugqociwlkmkpiyhnsmquvnbvpwuhevymeedokrwhxuzkqwmprsukyzqojmakoumfkrdcpxkm...

output:

2976

result:

ok single line: '2976'

Test #18:

score: 0
Accepted
time: 0ms
memory: 9744kb

input:

100 100
cbhpdvssjrpqjmavmejyvuujnhfmuvorrysrcwjaupwvcdcpscxfitcfshkpzrxecfleylgxrifofqqgobsrjddnppzxnsajvuvi
cdhpdvsbfrpijmavmfjyvuujnhfmuvyhrysccwjwdpwvadcpscbeitcfshkphqxehfleylgtrifofqdgobsrfddeppzxgfgjvuvi
cbhpdvsbjrpijmamsfjyvuujnhfmuvohrssrcvmadhwkadzpxcbgitcfshkpzrxecfleylgtrkfofqqgobspfddncp...

output:

1013

result:

ok single line: '1013'

Test #19:

score: 0
Accepted
time: 3ms
memory: 9692kb

input:

100 100
rrjtosvogmeeroxcuwcqfeokysmojwaqykozyowbzshirekmzmihvwfvofmcwsoggamybhfkctfdsutistyfrfwkmbqdvzeukerl
rrjtosvogmeeroxcuwcqfeokysmojwaqykozyowbzshirekmzmiuvwfvofmcwsoggamybhfkctfdsubistyfrfwkmbqdvkeukerl
rrjtosvogmeeroxcuwcqfeokysmojwaqykozyowbzshirekmzmiuvwfvofmcwsoggamybhfkctfdsutistyfrfwkmb...

output:

106

result:

ok single line: '106'

Test #20:

score: 0
Accepted
time: 3ms
memory: 9716kb

input:

100 100
nzebhdezrjnhrjxhhwqmjftcoxhsevtmobtlaaehhgpwxfyzieoujqsllvfacacroiwwaonefqftvoskhcuianvsgoxilyqhjwbn
nzebhdezrjnhrjxhhwqmjftcoxhsevtmobtlaaehhgpwxfyzieoujqsllvfacacroiwwaonefqftvoskhcuianvsgoxilyqhjwbn
nzebhdezrjnhrjxhhwqmjftcoxhsevtmobtlaaehhgpwxfyzieoujqsllvfacacroiwwaonefqftvoskhcuianvsgo...

output:

0

result:

ok single line: '0'

Test #21:

score: 0
Accepted
time: 3ms
memory: 9696kb

input:

100 100
bomfenhyqlngsltnxklncetcdmifzltzbsxfhkvdfdtcdaltonyauxdwxpjupetfpggncddbtvsxobfosfequlptqcpinqaxtqgu
fyiqiadjkflwmnielpjpvaonmdhaoycbfyeqdnmjlbhffdzbeflnttefhtgegwqdkurfumvlfpnoprxhzeobddsveiluxfxysnas
mqcrdvfbnqwevgbzwidatimstssdkxrdwoakyxrnsejgazpxxscwwjwbfgahzvnefsdrxvhpanitchysmxjfkgflag...

output:

9600

result:

ok single line: '9600'

Test #22:

score: 0
Accepted
time: 3ms
memory: 9752kb

input:

3 2
xy
uy
ux

output:

2

result:

ok single line: '2'

Test #23:

score: 0
Accepted
time: 3ms
memory: 9748kb

input:

10 5
ccded
ececd
dbcbe
aebbc
deccc
beeab
adabe
edaee
ecdec
cddad

output:

35

result:

ok single line: '35'

Test #24:

score: 0
Accepted
time: 3ms
memory: 9748kb

input:

2 100
qpdnytnckmgeutlfodaiqdpfqkyxrljplxscbzrqrefjdtipjioalqzycqfqezqpgkmmgqeicrridufyjrvacqvrczzwmnzbplta
blhzdjhmdriwkxbfsoowgnnxcxocyhiarvdqsvhgekpoaevjadrohsthzlgtokpxoqfxyrllwzsdhtvkkrwgpiwzspsrnnyfqklq

output:

97

result:

ok single line: '97'

Test #25:

score: 0
Accepted
time: 1ms
memory: 9696kb

input:

2 100
ecvdqsgbmmqakcalgandcuvooxraxthgjhdjdgtghjtowcwcbkvnqxusafauizhcwzjojlyrtepmiqroadkhbkbwrkrnxtaxhmuk
ecvdqsfgmmqawfalqlndcuvgoxgaxthgjhdjdvsmhjfowcwabkvyqyusafhurpxbwzjojlyitepmihroadkhplbwnkrnptaxhmuk

output:

26

result:

ok single line: '26'

Test #26:

score: 0
Accepted
time: 3ms
memory: 9728kb

input:

100 1
y
m
y
s
u
m
q
s
w
m
h
v
w
f
q
u
a
z
j
w
d
u
z
z
m
t
m
a
q
h
j
k
d
l
v
h
e
k
n
d
f
z
c
k
w
o
z
i
y
u
x
k
u
j
i
k
c
h
k
u
g
y
d
i
b
y
s
a
a
n
u
h
d
w
c
g
c
r
r
v
g
l
k
t
o
v
w
j
s
c
h
g
d
p
b
m
h
m
g
l

output:

93

result:

ok single line: '93'

Test #27:

score: 0
Accepted
time: 1ms
memory: 9696kb

input:

100 1
y
c
y
c
k
x
y
x
k
u
y
c
u
u
c
c
x
c
k
c
c
x
u
x
u
y
u
x
k
x
u
u
c
y
k
u
c
c
y
u
y
y
k
x
y
y
y
k
u
c
y
u
c
y
y
y
u
y
u
c
c
x
y
u
x
x
u
k
u
u
u
k
y
y
u
y
k
k
u
y
k
c
k
x
u
k
y
c
y
c
y
x
c
c
u
c
c
x
c
u

output:

75

result:

ok single line: '75'

Test #28:

score: 0
Accepted
time: 3ms
memory: 9720kb

input:

2 80
iyglnpywolcyqowvexzvcecqqkybyllgswtahydjljkanevknyrcpycwclbicggpvananlqbogafpgud
jamdzqgzjzbkievqumqzjbiuuhbgrrjgqrynwlmolhvstkljzvjykbtgljyvgzjzsxxhdzggfcmyxgjr

output:

77

result:

ok single line: '77'