Рад сообщить вам, что C++14 добавлен в список поддержанных языков на Codeforces. Выбор компилятора пал на MinGW-w64, версия GCC 6.2.0 (будем обновлять по мере выхода). Если у вас Windows, то установить именно эту сборку можно из PBOX одной командой pbox install mingw-w64
.
Кроме новомодных фишечек C++14 (не уверен, что есть много полезного для соревнований), есть такие плюсы:
- эта сборка быстрее mingw-tdm 5.1.0 работает с cin/cout — например перевернуть последовательность 106 целых чисел от 1 до 106 работает 1.5 секунды вместо 2.5 (и 0.3 вместо 1 при использовании
std::ios::sync_with_stdio(false)
) - корректно работает вывод double как со спецификаторами как %f так и %lf (читать надо с помощью %lf)
- корректно работает ввод-вывод long double как со спецификатором %Lf
- корректно работает ввод-вывод long long как с %lld так и с %I64d
Вероятно, чтобы уменьшить не очень нужное разнообразие реализаций C++ через некоторое время MinGW С++ и MinGW С++11 будут исключены, тем более что их сложно обновить до GCC 6 из-за сложностей с обратной совместимостью. Конечно, через некоторое время C++14 появится и в Polygon.
Are there any nifty features like those from c++11?
Mostly for jury it will be good idea to use apostrophe to separate thousands (say, in validators) like:
1e9 is in C++ for already long time :). It is by far the best way of inputting large bounds in my opinion.
as long as it doesn't fail silently
Yeah, I was aware of that and I silently expressed that by subtle choice of words =). That's why I said "bounds" not "numbers" :D. One should be aware of that however that's very rare usage whereas inputting something like 1e5 + 5 needs to be done in literally almost every problems.
Don't write comment if you know it may mislead someone.
"My comment may be interpreted in such a way that it's correct" isn't a strong argument.
Yeah, I guess it could have been misleading. Sorry for that. I had mentioning it in my mind, but I was in a bit of hurry and was writing from mobile, so that's because I chose replacing "numbers" with "bounds" =p.
...
With just a little more typing, maybe do
int64_t x = (int64_t) 1e18 + 1;
?Is it guaranteed to work?
it works only accidentally.
What exactly here is an 'accident'? Fact that (int64_t)1e18 == 1000000000000000000?
more like fact that
2 | 10
(I mean base used in computers is divisible by base used by people, not particular numbers), so 10^n is divisible by several powers of 2Maybe this could be a solution? You may pre-define as many as you want in your default code so you won't have to type it every time.
Or simply this.
Please could you update the source code highlighter to support this feature, because the current one thinks that those apostrophes are character literals and the formatting becomes ugly.
Now you can write auto in lambdas, make recursive dfs in lambda without unnecessary overhead, etc
What overhead are you talking about?
virtual call in
std::function
.More eloborate answer here http://www.pedromelendez.com/recursive-lambdas-in-c14/
Thanks!
you now can do things like this
MikeMirzayanov, почему бы не добавить компилятор MS C++ 2013 или 2015?
Зачем он тебе? Все что есть там, будет и в этом компиляторе
Например, на домашнем компе стоит MS VS 2013/2015, используется для компиляции и отладки перед отправкой. То, что компилируется в MS VS, далеко не всегда компилируется в GCC. Аналогично, то, что правильно работает в MS VS, может неправильно работать в GCC. Все это потому что MS VS иногда "прощает" отступление от стандарта и не делает UB там, где это может сделать GCC. А во время раунда тратить время на то, чтобы прогнать решение в двух компиляторах — непозволительная роскошь.
DmitriyH дело говорит. Пишу в Visual Studio и испытываю неудобства из-за различий компиляторов.
Ага, и кое-что лишнее будет. А именно, баги компилятора. На Codeforces уже миллион постов о багах в g++, а вот на MS C++ пока никто особо не жаловался.
У MS компилятора тоже полно багов, но жалуются меньше, т.к. на codeforces им пользуются реже.
Поддерживаю. На каждом первом контесте постоянно получаю ошибку компиляции, забывая, что этот компилятор устаревший и не поддерживает for (auto a : b) UPD: совсем забыл про инициализацию pair с помощью {a, b} вместо б-гомерзкой make_pair()!
MS VS C++ 2015!
Finally!
Actually, %lld/%I64d already worked correctly about 3-4 years.
So the warning about %lld when submitting should be removed then?
EDIT: I just found out that there is a don't show again tickbox to prevent the warning from showing up again.
I've been on CF about 3-4 years :D
I thought the warning still existed because it didn't work yet...
more like
Finally!
Ah, classic.
will xcode be supported at any time in the future /?
UPD : i meant the C++ language that xcode uses ... it's a bit strange from MSVS2010 and C++11 .... i wish that some day xcode will be a language to submit like MSVS
xcode is not a language.
read the Update :D
i think you mean the clang++ compiler since thats what Xcode uses
Testing is done on Windows and clang doesn't fully support Windows yet.
What are you talking about? It surely does.
If it did, Chromium would use clang on Windows by default and would never look back. Google is working on this issue, so hopefully we don't need to wait long.
MSVC has a better optimizer, so the release builds are built with it. Clang is widely used internally though.
Hoora!! so what is g++14?!
What's the different between g++11 & g++14?
One of the most interesting features in aspect of competitive programming is:
auto f(auto i, auto j) { return i < j; }
. Now both return type and parameter types are automatically resolved while compiling — it might save some bytes.Also don't forget about this :)
I'm sorry if this is out of topic, but when did CF completely remove Java 7 ? I recently realized that during contest #366, I submitted A and B using Java 7, and C onwards, Java 8 was the only Java version available..Was Java 7 removed right during the contest ?
Wow!!! great news.
A word of warning: looks like scanf is much slower on C++14 than it was on C++11. Here are three submissions using almost the same code on a problem:
So if you're using C++14, looks like it may be best to avoid scanf/printf now.
Edit: As pointed out below, a possible workaround is adding "#include <stdio.h>" before all other headers to the code, but this may break other things in the standard library (I don't know exactly what): 20295608
That sounds like a huge disadvantage of a new version, it means that it's not possible to simply replace current compilers for C++98 and C++11 with a new one as it would fail lots of already working solutions. Can anybody using Windows investigate the reason of such slowdown?
Probably the same reason why it's more accurate; while old compiler used to call the functions in the MSVCRT (Microsoft C Runtime Library), mingw-w64 took the approach of reimplementing the standard library.
I've tried other problem and got these results:
The reason I chose that specific problem was because the actual computations were extremely simple, so not much could change other than scanf/cin performance.
Your benchmark is spending the most time in priority_queue operations, so that's what you're really measuring (and it looks like C++14 priority_queue is much faster than C++11 priority_queue).
As you can see, reading the input of that problem with scanf takes 150ms on C++14 (20294340) and only 50ms on C++11 (20294356)
By including stdio.h as mentioned in Bedge's comment the input now takes only 15ms in C++14 (20295451) and the whole solution takes 187ms (20295427)
Del
20294551 c++14 scanf stdio.h 265ms
20294631 c++14 scanf cstdio tle
Is there any reason why this would happen?
Funny stuff!
As I can see in the mingw-w64 headers, including
<cstdio>
includes<bits/c++config.h>
which includes<bits/os_defines.h>
which contains the following code:If this file doesn't get included, it uses MSVCRT implementations of scanf/printf, just like the C++11 compiler.
I believe if it's not included, some incompatibilities between between already built libstdc++ and existing code may arise and break something.
Sorry for bothering you but do you have any idea whether this problem still exists if I include <bits/stdc++.h> instead :)) Thanks so much
Some good news for stdio haters :)
Did somebody mention me?
Was waiting for this comment! :P
.
So after half a year...**C++17** will be supported?
__int128 is still not supported... Linux g++ supports it and thus it is available in most of online judges including ICPC WF judge.
mingw-w64 also supports it, but in the 64-bit version (I think Linux g++ only supports it in 64-bits as well, no?). Mike probably installed 32-bit version, which doesn't have __int128.
I wish we had __int128 here too :c
It's because testing server has 32-bit OS, I think. :(
Can anyone help? Where can I get a C++14 for free? Does anyone has a hyperlink leads to the download page?
You can find download installer button in the upper right corner in this link.
You don't need to install it, here you go.
Whataya mean?
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf
pbox install mingw-w64: FATAL [2016-08-31 16:20:50,263] Unexpected error: Can't find mingw-w64$6.2.0.pbox.7z for 'mingw-w64$6.2.0'. Are you sure the package exists? java.lang.RuntimeException: Can't find mingw-w64$6.2.0.pbox.7z for 'mingw-w64$6.2.0'. Are you sure the package exists? at me.pbox.command.InstallCommand.run(InstallCommand.java:44) at me.pbox.command.DefaultCommand.run(DefaultCommand.java:21) at me.pbox.Main.main(Main.java:104)
20301838: MS C++, scanf, 1559 ms
20301823 : GNU C++11, scanf, 1731 ms
20301815 : GNU C++14, scanf, TLE (time limit 3 seconds)
<cstdio>
includedCheck this.
20318845 TLE,
<cstdio>
is not included,stdio.h
and<iostream>
are included20318836
<iostream>
is not included and ACInclude
stdio.h
beforeiostream
.Before: 20305701
After: 20305501
Свершилось!!! Спасибо MikeMirzayanov.
Those who are using Windows 10 and anniversary update, they will get linux beta version in developer mode. I am not sure about earlier version of windows 10 but this one I have tried. I think this will remove the necessity of CYGWIN or other tools for windows.
How to enable it — Steps to follow — 1) go to settings 2) update and security 3) for developers, click on developer mode
After that- 1) open control panel 2) go to program and features(if you can't find it go to uninstall program) 3) you will see turn features on or off(you can directly search it in cortona or search bar), click on it 4) you will see "window subsystem for linux beta", include the folder and its sub folders and now you have workable linux.
Thank you Mike for your work making this feature possible :)
I'm wondering if this is the first blog, which has +1000 upvotes ?
No, I've already seen one with nearly +1400.
http://mirror.codeforces.com/blog/entry/16473
No
PSA/WARNING: The linked page just contains a bunch of flashing colors; don't click if you have epilepsy or something like that.
When C++ 14 will appear on Polygon?
Не понимаю: в каком смысле сложно обновить C++11 до GCC 6? Надо просто скопировать конфигурацию C++14 и добавить флаг
-std=gnu++11
.Подскажите, пожалуйста, есть ли страница, где собраны актуальные сведения по списку поддерживаемых компиляторов и используемых флагах?
Ссылку на FAQ не наблюдаю, гуглом ищется Entry #79, но там, к примеру, нет упоминания о GCC 6.2.0.
GNU C++ 14 is removed? i used to submit in C++14 but unable to find it in the dropdown options now.